TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Image filetype conversion (http://www.talkphp.com/advanced-php-programming/3458-image-filetype-conversion.html)

jcorradino 10-09-2008 02:42 AM

Image filetype conversion
 
ok, I am working on a project where the client wants to be able to upload images to his site. The problem: the files are inconsistent. They are different sizes, have no set naming structure, and are different formats - mostly jpeg, tiff, and png.

Resizing and renaming is easy enough through php, but the filetype is the problem, have any idea if/how I can convert the image from tiff or png to jpg using php?

Thanks,

Jason Corradino

ReSpawN 10-09-2008 07:00 AM

As far as I know, JPEG and TIFF coding don't come close to looking like eachother so I think that's a no-go. The smartest thing for you to do, is just simply sort them by type or let the customer upload regular images, since TIFF usually is way to big (print size, 300DPI).

One way you can try, is to find some online converter, but I guess that'll cost money. Sorry to burst your bubble, but I don't reckon it's possible. Perhaps the other Guru's might now something.

jcorradino 10-09-2008 07:50 AM

Quote:

Originally Posted by ReSpawN (Post 18709)
Sorry to burst your bubble, but I don't reckon it's possible. Perhaps the other Guru's might now something.

No worries, I was thinking that it wasn't possible without using something other than php. Just going to have to tell the client that he will need to convert the images if he wants to add more...

ReSpawN 10-09-2008 08:32 AM

Indeed. You can download simple converters. Just make a small read-me for the client and he'll be able to all the work himself. On the other hand, if you're in for the money, just tell him to send you the pictures and you'll do it yourself. :-D

Salathe 10-09-2008 12:03 PM

You can use PHP's GD functions to load in the image (gif, png, tiff, whatever) and save it out in jpg format with only a couple of lines of code. Unless I'm missing the actual problem here, it seems a simple enough solution.

sketchMedia 10-09-2008 12:45 PM

TIFF can be a container format for images and one of the encoding types of TIFF is JPEG aswel as large 300+ DPI vector images for print etc.

Anyway, Salathe has one solution although i dunno how it would fair if a TIFF was used, as there isn't a TIFF function in PHP's GD API.

You could also use imagemagick, if you have a *nix box with it installed, you can do this:
PHP Code:

exec('convert image.tif image.png'); 

That will convert the image.tif (which is a TIFF) to a png called image.png in the current directory.

You can even do the conversion and resize all in one:
PHP Code:

exec('convert image.tif -resize 200x200 image.png'); 


ReSpawN 10-09-2008 07:18 PM

I am not known with imagemagick since it has been disabled on my server. ;) Good solution non the less. I advise you to try those two.


All times are GMT. The time now is 01:29 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0