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
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-09-2008, 03:42 AM   #1 (permalink)
The Wanderer
 
jcorradino's Avatar
 
Join Date: Sep 2008
Posts: 16
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 - Web Development/Design, SEO, UI, Information Architecture, Accessibility Consultant, and all around great guy
My Site | My Twitter | My Delicious | My Facebook | My Most Recent Site | Download My vCard
jcorradino is offline  
Reply With Quote
Old 10-09-2008, 08:00 AM   #2 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 445
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, 08:50 AM   #3 (permalink)
The Wanderer
 
jcorradino's Avatar
 
Join Date: Sep 2008
Posts: 16
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 - Web Development/Design, SEO, UI, Information Architecture, Accessibility Consultant, and all around great guy
My Site | My Twitter | My Delicious | My Facebook | My Most Recent Site | Download My vCard
jcorradino is offline  
Reply With Quote
Old 10-09-2008, 09:32 AM   #4 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 445
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, 01:03 PM   #5 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 715
Thanks: 2
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 is offline  
Reply With Quote
Old 10-09-2008, 01:45 PM   #6 (permalink)
The Frequenter
Advanced Programmer Top Contributor Good Samaritan 
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 471
Thanks: 26
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'); 
__________________

Last edited by sketchMedia : 10-09-2008 at 02:14 PM. Reason: Dreadful spelling
sketchMedia is offline  
Reply With Quote
Old 10-09-2008, 08:18 PM   #7 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 445
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 08:28 AM.

 
     

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