TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-09-2008, 02:42 AM   #1 (permalink)
The Contributor
 
jcorradino's Avatar
 
Join Date: Sep 2008
Posts: 36
Thanks: 2
jcorradino is on a distinguished road
Default 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
__________________
Jason Corradino
Applications Developer, Interactive Support - Tribune Technology
J2EE Development, Script Tinkering - Develop, Support, and Maintain Tribune websites.
jcorradino is offline  
Reply With Quote
Old 10-09-2008, 07:00 AM   #2 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
The Following User Says Thank You to ReSpawN For This Useful Post:
jcorradino (10-09-2008)
Old 10-09-2008, 07:50 AM   #3 (permalink)
The Contributor
 
jcorradino's Avatar
 
Join Date: Sep 2008
Posts: 36
Thanks: 2
jcorradino is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
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...
__________________
Jason Corradino
Applications Developer, Interactive Support - Tribune Technology
J2EE Development, Script Tinkering - Develop, Support, and Maintain Tribune websites.
jcorradino is offline  
Reply With Quote
Old 10-09-2008, 08:32 AM   #4 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 10-09-2008, 12:03 PM   #5 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,239
Thanks: 3
Salathe is on a distinguished road
Default

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.
__________________
salathe@php.net
Salathe is offline  
Reply With Quote
Old 10-09-2008, 12:45 PM   #6 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 836
Thanks: 31
sketchMedia is on a distinguished road
Default

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'); 
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)

Last edited by sketchMedia : 10-09-2008 at 01:14 PM. Reason: Dreadful spelling
sketchMedia is offline  
Reply With Quote
Old 10-09-2008, 07:18 PM   #7 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:47 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design