Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

file extension caps sensitivity

2011-06-23
2013-04-24
  • Karl Henselin
    Karl Henselin
    2011-06-23

    in helper.php, I recommend this change just to make things a bit easier on users that might have capital letters in their file extensions. This trouble took a while for me to figure out since the
    if (preg_match("/jpg|jpeg/",$image)){$src_img=imagecreatefromjpeg($image);}
    if (preg_match("/png|PNG/",$image)){$src_img=imagecreatefrompng($image);}

    if (preg_match("/jpg|jpeg/i",$image)){$src_img=imagecreatefromjpeg($image);}
    if (preg_match("/png|PNG/i",$image)){$src_img=imagecreatefrompng($image);}

    In other placesthe insensitivity flag is there, so it finds the image as a jpg, but fails to classify it as a jpg when doing the image conversion on line 54 or 55. Perhaps it would be better to do something like this though for those 2 lines?

    $imagetype = exif_imagetype($image);
    if ($imagetype == 2){$src_img=imagecreatefromjpeg($image);}
    if ($imagetype == 3){$src_img=imagecreatefrompng($image);}

    I decided to go with the third one.

     
  • Karl Henselin
    Karl Henselin
    2011-06-23

    Sorry that was illegible. I wish that the typing box were a bit taller.

    in helper.php, I recommend this change just to make things a bit easier on users that might have capital letters in their file extensions. This trouble took a while for me to figure out since in other placesthe insensitivity flag is there, so it finds the image as a jpg, but fails to classify it as a jpg when doing the image conversion on line 54 or 55.

    if (preg_match("/jpg|jpeg/",$image)){$src_img=imagecreatefromjpeg($image);}
    if (preg_match("/png|PNG/",$image)){$src_img=imagecreatefrompng($image);}

    changed to

    if (preg_match("/jpg|jpeg/i",$image)){$src_img=imagecreatefromjpeg($image);}
    if (preg_match("/png|PNG/i",$image)){$src_img=imagecreatefrompng($image);}

    Or, perhaps it would be better to do something like this though for those 2 lines?

    $imagetype = exif_imagetype($image);
    if ($imagetype == 2){$src_img=imagecreatefromjpeg($image);}
    if ($imagetype == 3){$src_img=imagecreatefrompng($image);}

    I decided to go with the third one.

     
  • Johan Ekblad
    Johan Ekblad
    2011-06-23

    thanks again, did as you suggested (third one) and used the defined constants IMAGETYPE_JPEG and IMAGETYPE_PNG. Also made a 2.0.5 bugfix release, will upload it at sourceforge in a moment.