#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    6
    Rep Power
    0

    Converting After Upload


    I would like to convert an image file to jpg directly after uploading, before saving to disk. What is the best way to do this?
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    300
    Rep Power
    9
    Why not just reject any image type that isn't a JPG for example GIF, PNG, BMP and ask the user to convert their file type to a JPG.

    Regards,

    NM.
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    The image is saved to the disk in a temporary location when it is uploaded; you can't convert it before that happens. However, you can convert it before you move the image into its final location on the disk.

    PHP's GD extension could be used to perform the conversion, or on Linux you could use ImageMagick's convert command.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo