how to use the unit "px"?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
uwestoehr
Posts: 1439
Joined: Sun Jan 27, 2019 3:21 am

how to use the unit "px"?

Postby uwestoehr » Sat Mar 07, 2020 9:55 pm

For TechDraw I wanted to use the unit "px" for the width and height of images in pages. I realized that the unit system has no unit for pixel yet. it is clear that a pixel is no defined length and therefore it doesn't fit into the SI unit system.

The question is how I can nevertheless use the unit "px" (for example for a App::Propertyxxx).
openBrain
Posts: 3927
Joined: Fri Nov 09, 2018 5:38 pm

Re: how to use the unit "px"?

Postby openBrain » Sat Mar 07, 2020 10:42 pm

You could use CSS defined standard, which tells 1px=1/96in. But that's definitely weird to use px as a unit.
usbhub
Posts: 280
Joined: Tue Apr 02, 2019 8:22 pm
Location: Earth

Re: how to use the unit "px"?

Postby usbhub » Sat Mar 07, 2020 11:28 pm

openBrain wrote:
Sat Mar 07, 2020 10:42 pm
You could use CSS defined standard, which tells 1px=1/96in.
If I remember right, there were a change in the standard (1/92 or so), so that can result in another problem.
openBrain
Posts: 3927
Joined: Fri Nov 09, 2018 5:38 pm

Re: how to use the unit "px"?

Postby openBrain » Sun Mar 08, 2020 12:13 am

usbhub wrote:
Sat Mar 07, 2020 11:28 pm
If I remember right, there were a change in the standard (1/92 or so), so that can result in another problem.
Not at all. ;) There has been a weird definition in Inkscape SVG format using a default user unit at 90 ppi, up to version 0.92. I guess that's what causes your confusion. But it's not related.
User avatar
uwestoehr
Posts: 1439
Joined: Sun Jan 27, 2019 3:21 am

Re: how to use the unit "px"?

Postby uwestoehr » Sun Mar 08, 2020 2:02 am

openBrain wrote:
Sat Mar 07, 2020 10:42 pm
You could use CSS defined standard, which tells 1px=1/96in. But that's definitely weird to use px as a unit.
Why is that weird? It is the standard unit for image sizes. See for example this screenshot:
FreeCAD_AQtYH746y3.png
TD screenshort
FreeCAD_AQtYH746y3.png (12.92 KiB) Viewed 162 times

Yo see there units of mm and ° but for the image size there is no unit. For IT affine persons it might be clear that the 100 means 100 pixel, but others might think these are mm since no unit means either no unit or often mm.

Yes, it is a very minor issue.
chrisb
Posts: 24294
Joined: Tue Mar 17, 2015 9:14 am

Re: how to use the unit "px"?

Postby chrisb » Sun Mar 08, 2020 7:22 am

uwestoehr wrote:
Sun Mar 08, 2020 2:02 am
Why is that weird? It is the standard unit for image sizes. See for example this screenshot: FreeCAD_AQtYH746y3.png
Aren't these unrelated issues? The 100x100 shown in your screenshot define the size of the source image to be extracted, not how big it is shown. Otherwise it would not zoom with the rest of the page. The px/inch conversion determines the size on the page. What you show in the image should indeed have the unit px.
openBrain
Posts: 3927
Joined: Fri Nov 09, 2018 5:38 pm

Re: how to use the unit "px"?

Postby openBrain » Sun Mar 08, 2020 10:40 am

uwestoehr wrote:
Sun Mar 08, 2020 2:02 am
Why is that weird? It is the standard unit for image sizes.
Yes. I should have said more precisely that it is weird to use px to define dimensions.
'Size' is a bit ambiguous. Like in 'file size'. Actually it's similar to a weight. In case of a picture, resolution (dpi or ppi) would be similar to a density, and then dimensions are obtained by weight(size)/resolution. ;)