473,756 Members | 8,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is it possible to convert image types (GD2)

(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif,
png) into another type? Especially, I know I can read a gif with GD2, but I
really need to be able to save it as a png. Is that possible?

-dg
Jul 17 '05 #1
7 6578
dan glenn schrieb:
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif,
png) into another type? Especially, I know I can read a gif with GD2, but I
really need to be able to save it as a png. Is that possible?


Why don't you just have a look at the documentation?

http://www.php.net/manual/en/function.imagepng.php

Regards,
Matthias
Jul 17 '05 #2
On Sat, 19 Jun 2004 07:13:48 GMT, "dan glenn" <da********@yah oo.com> wrote:
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif,
png) into another type? Especially, I know I can read a gif with GD2, but I
really need to be able to save it as a png. Is that possible?


Yes, it is.

--
Andy Hassall <an**@andyh.co. uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #3
"dan glenn" <da********@yah oo.com> wrote in message
news:MI******** ***********@new ssvr29.news.pro digy.com...
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif,
png) into another type? Especially, I know I can read a gif with GD2, but I really need to be able to save it as a png. Is that possible?


You can convert gif into png or jpeg but no vice-versa. The imagepng() and
impagejpeg() will save the image into the respected format.
Jul 17 '05 #4

"Chung Leong" <ch***********@ hotmail.com> wrote in message
news:xc******** ************@co mcast.com...
"dan glenn" <da********@yah oo.com> wrote in message
news:MI******** ***********@new ssvr29.news.pro digy.com...
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif, png) into another type? Especially, I know I can read a gif with GD2,
but I
really need to be able to save it as a png. Is that possible?


You can convert gif into png or jpeg but no vice-versa. The imagepng() and
impagejpeg() will save the image into the respected format.


OK - I'm now saving .gif's to .png's, but I note that I lose the
transparancy (if there is one) in doing so. How can I maintain the
transparancy in the PNG???

-dg
Jul 17 '05 #5
"dan glenn" <da********@yah oo.com> wrote in message
news:UF******** ***********@new ssvr29.news.pro digy.com...

"Chung Leong" <ch***********@ hotmail.com> wrote in message
news:xc******** ************@co mcast.com...
"dan glenn" <da********@yah oo.com> wrote in message
news:MI******** ***********@new ssvr29.news.pro digy.com...
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif, png) into another type? Especially, I know I can read a gif with GD2, but
I
really need to be able to save it as a png. Is that possible?


You can convert gif into png or jpeg but no vice-versa. The imagepng()

and impagejpeg() will save the image into the respected format.


OK - I'm now saving .gif's to .png's, but I note that I lose the
transparancy (if there is one) in doing so. How can I maintain the
transparancy in the PNG???


Hmmm, I just tried it and it works correctly. I'm using 4.3.6. Maybe GD is
saving the PNG with alpha-channel info (which IE doesn't support) instead of
single color transparency. View the image in Netscape or open it with
Photoshop and see if transparency is there.
Jul 17 '05 #6

"Chung Leong" <ch***********@ hotmail.com> wrote in message
news:ie******** ************@co mcast.com...
"dan glenn" <da********@yah oo.com> wrote in message
news:UF******** ***********@new ssvr29.news.pro digy.com...

"Chung Leong" <ch***********@ hotmail.com> wrote in message
news:xc******** ************@co mcast.com...
"dan glenn" <da********@yah oo.com> wrote in message
news:MI******** ***********@new ssvr29.news.pro digy.com...
> (PHP4.3.4) Is it possible to change an image that's in one type
(jpg,
gif,
> png) into another type? Especially, I know I can read a gif with
GD2, but
I
> really need to be able to save it as a png. Is that possible?
>

You can convert gif into png or jpeg but no vice-versa. The imagepng()
and impagejpeg() will save the image into the respected format.


OK - I'm now saving .gif's to .png's, but I note that I lose the
transparancy (if there is one) in doing so. How can I maintain the
transparancy in the PNG???


Hmmm, I just tried it and it works correctly. I'm using 4.3.6. Maybe GD is
saving the PNG with alpha-channel info (which IE doesn't support) instead

of single color transparency. View the image in Netscape or open it with
Photoshop and see if transparency is there.


Yes, you're right - the transparency is there. It was just IE. Gad. OK - is
there a way I can make imagepng() save the PNG as a palette-based (8-bit,
256-color) single-color transparancy? (These will work in IE, as they don't
use the alpha channel)
Jul 17 '05 #7
"dan glenn" <da********@yah oo.com> wrote in message news:<RF******* *********@newss vr25.news.prodi gy.com>...
<snip
Hmmm, I just tried it and it works correctly. I'm using 4.3.6. Maybe GD is
saving the PNG with alpha-channel info (which IE doesn't support) instead

of
single color transparency. View the image in Netscape or open it with
Photoshop and see if transparency is there.


Yes, you're right - the transparency is there. It was just IE. Gad. OK - is
there a way I can make imagepng() save the PNG as a palette-based (8-bit,
256-color) single-color transparancy? (These will work in IE, as they don't
use the alpha channel)


You may be interested in phpSt.Justin's wonderful article on the
subject <http://www.koivi.com/ie-png-transparency/>

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7190
by: kristofl | last post by:
Hi all, I store images in my DB as BLOB. When I want to place them in an html table, I want to determine the width of the image in order to asign the correct width to the column inside table. For JPEGs this is working fine, this is my code: $image = @imagecreatefromstring($r); return @imagesx($image);
6
7744
by: Useko Netsumi | last post by:
Hi, I'm trying to experiment with the GD2 library(or GD for that matter) for win32 platform BUT could not find any that support it. Could you tell me where to find the binary of it? Thanks.
0
2043
by: Klaus Boehmer | last post by:
Hello, I'm trying to install gd2 with gif-support as an extension with php4. I compiled the patched version of gd2 - fine. I compiled php4 with gd=shared - fine. I installed it and restarted apache and I get: undefined symbol: gdImagePngCtx I recompiled php4 and included gd and everything works fine. But as soon as I compile gd2 as shared things mess up. I've searched 2 days for a solution, but didn't find anything. Please help me!
4
2868
by: Ruby Tuesday | last post by:
I have a section(185pixelsx 185pixels) in my web page to display an image that is stored in a directory. Using php, how do you resize so if: the image dimension is smaller(width and height is less than 185pixels), display it in the center of the section if the width OR height is larger than 185pixel, resize them with aspect ratio maintained so both width and height is <= 185pixels. Then display it in the center of the section.
3
3987
by: tjh | last post by:
hi - i'm a bit new to PHP - i've been messing around with the GD2 image functions and was wondering: i see a lot of information about converting a color image to grayscale but i can't figure out how to determine whether an image (GIF or JPG) is grayscale in the first place. is there a way to do this in PHP?
1
1901
by: Leif Wessman | last post by:
Hi, How can I/Is it possible to convert a jpg image to a favicon using php (including resizing it if needed)? Leif
5
4729
by: Jim | last post by:
I've heard that resizing images through PHP (either GD2 or ImageMagick) is a processor intensive exercise. I'm setting up a site where users will be uploading up to 10 images along with the details of their product. For each image uploaded (max 500Kb), I'll be resizing it to create a small, medium and large version after which I'll discard the original. My worry is that as the site becomes more popular, the processor time spent resizing...
2
1956
by: Bob Bedford | last post by:
I've an image that is 300x225 pixels. I've to send this image to mobile phones using the mms. For this the best result is given using 120x160 pixels. So I may generate a 120 pixels large image, but I've a lot of unused space under the image, as scaling proportionally, my image is then 120x90. how to enlarge the image in order to get the picture 120x90 and then a white stripe where I may write the website (or put the logo). The...
12
2965
by: laredotornado | last post by:
Hi, I'm using PHP 5. I was wondering given an image, a.jpg, how can I make an image that would look like you slid a white index card (which I have a file, white.jpg with the same dimensions as a.jpg) over a.jpg? Note that you'd be sliding the image from top to bottom or from left to right, but not both. Thanks, let me know if this makes sense ... it's a litlte hard to describe.
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.