Hello All,Ineed a help in uploading image in which i want that the image which is of 150 dpi(dots per inch ) ,is only upload and smaller den that show messge .My issuue is that how i apply tht :( please give me some direction in tht

Recommended Answers

All 7 Replies

If you use Imagick, it has a method to determine resolution. Not sure if GD provides one. Otherwise there's still an option to read it directly from the file (saw an implementation on SO).

thanks for quick reply but i am trying to use formula which dpi=(pixeles of lenght)/inches of lenght

pixles=width *height
and i am confusing in the inches of length is ?? or i am going in ryt direction ?

I don't understand your question. Can you give an example of what you want?

Hi,

I think the OP wants to check if a given image matches the minimum print sizes at a defined DPI:

<?php

    $image = 'img1.jpg';

    list($w, $h) = getimagesize($image);

    $dpi = 150;

    # current sizes in inches
    $inW = round($w / $dpi, 2);
    $inH = round($h / $dpi, 2);

    # min print sizes in inches
    $printW = 5;
    $printH = 5;

    echo PHP_EOL;

    if($inW >= $printW && $inH >= $printH)
    {
        echo "Correct, the print sizes at {$dpi}DPI are: {$inW} x {$inH} inches";
    }
    else
    {
        echo "This image is too small";
    }

    echo PHP_EOL;

With an image at 1920x1080 the result will be 12.8x7.2 inches. You can get the same result with ImageMagick, as suggested by Pritaeas, for example from the command line:

identify -format "%[fx:w/150] by %[fx:h/150] inches" img1.jpg

Docs: http://www.imagemagick.org/script/identify.php

thanks cereal ,but i am checking this code it echo same size 12.8x7.2 for any image "Correct, the print sizes at {$dpi}DPI are: {$inW} x {$inH} inches";

Please provide your code, otherwise it is difficult to help.

Thankyou cereal

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.