image information image information
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

image information

Started by utw, July 28, 2007, 02:20:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

utw

Hi,
I need to show image's dimension in centimeters (millimeters, metrical value ;) ) rather than in pixel in image's description box.
Is there any chance to do it? I take a look of the php code (editOnePic.php) but I cannot find anything. Maybe a plugin can help me?

Thanks a lot !

utw

Joachim Müller

Basically, there is no correlation between pixels and dimensions in centimeters, as this will depends on the resolution (dots per inch) and the output medium (print or screen). As Coppermine is not "aware" of the resolution (dots per inch), you can only come up with an actual calculation if you know the resolution of your files, i.e. if you're the only uploader. Subsequently, I suggest to review the overall idea.

Anyway, the formula is: Pixels to Inches: inches = pixels / dpi. The formula to convert inches to centimeters is: cm = inches * 2.54. Subsequently, the formula to convert pixels to centimeters is: cm = (pixels * 2.54) / dpi.
So if you know that all your images are e.g. 96dpi, you could come up with a working formula in PHP, which would roughly look like this (untested) piece of code:<?php
$dotsPerInch 
96;
$inchToCentimeterRatio 2.54;
$numberOfDecimals 2;
$dimensionInCentimeters floor( ( ($dimensionInPixels $inchToCentimeterRatio) / $dotsPerInch) * pow(10,$numberOfDecimals) ) / pow(10,$numberOfDecimals);
You will have to modify the function html_picinfo() in displayimage.php integrate this into Coppermine.

utw

Hi Gau Gau and thanks for your reply!
I appreciate your solution: I can also implement a pop-up from which you choose the right resolution in dpi and then display the correct size.
Or can coppermine guess the dpi from the file, in the way photoshop does?

Thank you.

Joachim Müller

Afaik there's no function in PHP's GD commands to determine this. If you have ImageMagick available, there might be a solution.

utw

Yes, I've got ImageMagick.
Could it be this an issue important for other users? i.e. should I post it in other forum's area rather than this?
Thanks!

Joachim Müller

Quote from: utw on August 08, 2007, 12:06:32 PM
Yes, I've got ImageMagick.
Then there's a chance that you could come up with some custom code to accomplish what you're up to. You'll need good coding skills though.

Quote from: utw on August 08, 2007, 12:06:32 PMCould it be this an issue important for other users?
Possible, but unlikely imo.
Quote from: utw on August 08, 2007, 12:06:32 PMshould I post it in other forum's area rather than this?
No. If we wanted this thread in another sub-board, we would have moved it there. Please stick to this thread.

utw

hi then and sorry for my late reply, but I went on vacation :)
the feature I was talking about was requested me by people interested in using coppermine as a tool to organize images (i.e. an archive).
while these images will be used in books or something that will be published on paper, you can realize how I (and they) need to know such informations.
In the meantime, I try to code something by myself or, better, getting helped by developers/coders...
Thanks for your kind replies!