#1
  1. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,095
    Rep Power
    220

    Get image dpi and other if it's an image


    Hey

    2 questions about images please shed light with your lightsabers.

    1 - I want users to upload image that is 300dpi and 90mmx55mm

    To make sure the file is image, how's this? Potential errors?
    PHP Code:
    if(isset($mediapath))
      {
        if(@
    is_array(getimagesize($mediapath)))
          {
            
    $image true;
          }
        else
          {
            
    $image false;
          }
      } 
    2 - I do this in Jquery modal, upload them to S3 and then when upload I do a bunch of other Jquery and replace a few image src attributes and show the design on screen.

    What would be the best way to check images dpi before I do all that.

    With
    PHP Code:
    $size getimagesize("tpe.png"); 
    I get
    Array ( [0] => 400 [1] => 253 [2] => 3 [3] => width="400" height="253" [bits] => 8 [mime] => image/png )
    That tells me nothing about dpi. That tells me less than nothing.
  2. #2
  3. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,180
    Rep Power
    9644
    DPI is not a property of an image but of the display medium used to show the image. Such as a monitor or printer. A "dot" is an arbitrary thing representing the smallest piece of an image (eg, pixel on a monitor, ink dot on a printer) and DPI is how many of those you can squeeze into an inch.

    300dpi is about 11.81px/mm ("pixel" not on a screen but as a coordinate on an image) so 90x55mm is ~1063x650px. Don't require that exact dimension, of course - set up an acceptable range on both dimensions.
    Last edited by requinix; July 14th, 2017 at 05:56 AM.

IMN logo majestic logo threadwatch logo seochat tools logo