how to use the unit "px"?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

how to use the unit "px"?

Post by uwestoehr »

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
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: how to use the unit "px"?

Post by openBrain »

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"?

Post by usbhub »

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
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: how to use the unit "px"?

Post by openBrain »

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
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: how to use the unit "px"?

Post by uwestoehr »

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:
TD screenshort
TD screenshort
FreeCAD_AQtYH746y3.png (12.92 KiB) Viewed 946 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
Veteran
Posts: 53951
Joined: Tue Mar 17, 2015 9:14 am

Re: how to use the unit "px"?

Post by chrisb »

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.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: how to use the unit "px"?

Post by openBrain »

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. ;)
Post Reply