tif to png with GD2

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

tif to png with GD2

Post by hongco »

Does anyone know how to convert tif to png on the fly with PHP using GD2?

I think imagemagick can do this.

Thanks
Last edited by hongco on Mon May 30, 2005 4:39 pm, edited 1 time in total.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

GD2 can't open TIFF files. So either you'll need to write a PHP script to open them, convert the data to a string GD can read, and save that as a PNG .. or just use Imagemagick.
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

hi onion,

i was wondering how we do that with GD?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

hongco wrote:i was wondering how we do that with GD?
Yes. And I told you.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

for clarification GD or GD2 doen't support tiff files.
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

phpScott wrote:for clarification GD or GD2 doen't support tiff files.
exactly! and I already know how to do that with imagemagick, but the problem with imagemagick is that you have to allow system command in php and turn off safemode in php.ini ...
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

hongco wrote:
phpScott wrote:for clarification GD or GD2 doen't support tiff files.
exactly! and I already know how to do that with imagemagick, but the problem with imagemagick is that you have to allow system command in php and turn off safemode in php.ini ...
So you know that it's not possible in GD2 .. yet you still posted the question.

Err..

Ok.
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

you are a difficult one, aren't you? haha j/k

at some point in your life, you might be wondering...hmm...."I know this one could not be done by such and such way, but do I know that for sure..maybe someone out there just figure out the new way"

That's the reason why inventions get invented every single day.

Furthermore, do not under-estimate the value of discussion. My question may be asked again by someone? and the answer you gave me can help them too.

Get a beer and keep yourself cool :lol: :lol:
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

It's public domain. I wonder why GD doesn't support it...
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

if you have googled and checked out other php resources and there is no answer there, what do you want us to do for you? Google around ourselves and check. If someone here knew the answer they would post it.
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

a useless thread, indeed. i am not here to argue with all non sense.
OP can lock it if you will.

:roll:
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

is that you have to allow system command in php and turn off safemode in php.ini
Not necessarily. You could post files in a certain directory and have a batch/cron process perform conversions. OK you would potentially have a slight time delay if part of a "workflow" (i.e where the PHP copies the file to the directory) but it could be a potential solution.

Although not part of your question, but a I thought I'd mention it for completeness.. I have had problems with converting uploaded JPG to TIFF with ImageMagick (toggle doesn't seem to work) to be read on a Mac (Quark) due to Mac's requiring big-endian and Windows assuming little-endian. In the end I had to use the Tifflib library to correct it.
Post Reply