Skip to main content
Inspiring
February 16, 2024
Answered

the centimeter values are not the same

  • February 16, 2024
  • 2 replies
  • 1815 views

when I go to the image/square size menu
I select centimeters and enter a value of 10cm
when I convert the action instead of 10cm I find the value of 283.000000, I can't understand where I'm wrong
someone help me for this.

 

This topic has been closed for replies.
Correct answer Stephen Marsh

I thought it was simpler Now I'll see if I can find something more intuitive.


Your recent topics have been about UXP.

 

Now it seems that you are using legacy ExtendScript?

 

It all depends on the current resolution, I'm not sure if this helps or not?

 

var theRes = app.activeDocument.resolution; // PPI
var theUnitAsCM = (theRes/2.54); // 1 CM
alert("The resolution in PPI divided by 2.54:\r" + theUnitAsCM + "\r\rHowever, we can't have a floating value!");
oneCMasPX = parseInt(theUnitAsCM); // 1 CM to PX integer
alert("1 CM in PX at the current Res:\r" + oneCMasPX);

 

 

 

2 replies

Stephen Marsh
Community Expert
Community Expert
February 16, 2024

You can set ruler units in your code, however, Photoshop is always using pixels as the native unit.

Inspiring
February 16, 2024

Stefano I have tried all the methods but none of them work for me, What's the point of putting centimeters if you can't use it?

Inspiring
February 17, 2024

Pixels are the native unit of measure.

 Canvas size and scripts allow for entry in inches, cm, mm etc., however, they are always going to need to be translated into pixels.


Stefano ho scoperto che per realizzare 1 cm servono circa 29px a 72dpi in modo da poter creare una formula, ma non ho proprio idea di come crearla. hai qualche idea?

 

la formula è questa

cm x dpi: 2,54

1x72:2,54=28,34

How do I get the calculation done for example if I put 1cm in edittext how to do the formula to do the calculation.

Legend
February 16, 2024

That value is probably pixels, not cm. Photoshop is a pixel-based editor, inches and cm are derived values.

At 72 pixels per inch, 10cm would be 283.4 pixels.

Inspiring
February 16, 2024

Thanks for the explanation
do you know how I could solve this problem

 

Legend
February 16, 2024

I don't understand what the problem is. Please explain.