dsdsdsdsd Posted May 5, 2008 Share Posted May 5, 2008 hello; I have only recently discovered that php has image-manipulation capabilities, which ofcourse is a different approach than using photoshop; can anyone shed light on when/why would a user need to imagecreatefrompng; seems to me if that a developer already has a png sitting on a server, there would not be a reason to create an image from it; any thoughts? thanks dsdsdsds Link to comment https://forums.phpfreaks.com/topic/104217-whenwhy-would-a-user-need-to-imagecreatefrompng/ Share on other sites More sharing options...
obsidian Posted May 5, 2008 Share Posted May 5, 2008 The image create functions are used when you wish to manipulate an image. If you wish to display a file with a watermark or other manipulation, and the original image is a PNG file, you would use said function. You would follow the same practice with a JPG, but use the createimagefromjpeg function call instead. **EDIT** Basically, think of it this way: the functions allow you to modify and display the image with modifications (or store it to disk) without ever actually modifying the original image. Link to comment https://forums.phpfreaks.com/topic/104217-whenwhy-would-a-user-need-to-imagecreatefrompng/#findComment-533547 Share on other sites More sharing options...
947740 Posted May 5, 2008 Share Posted May 5, 2008 .png files are rather large, so if a user wanted a .jpg version, or a smaller version, you could convert it to reduce file size. Link to comment https://forums.phpfreaks.com/topic/104217-whenwhy-would-a-user-need-to-imagecreatefrompng/#findComment-533548 Share on other sites More sharing options...
obsidian Posted May 5, 2008 Share Posted May 5, 2008 .png files are rather large, so if a user wanted a .jpg version, or a smaller version, you could convert it to reduce file size. This is usually only the case of improperly optimized images, though. A standard PNG file vs JPG can be optimized to be smaller and look better than a JPG of the same size. The biggest issue is that IE6 doesn't appropriately support PNG transparencies Link to comment https://forums.phpfreaks.com/topic/104217-whenwhy-would-a-user-need-to-imagecreatefrompng/#findComment-533549 Share on other sites More sharing options...
dsdsdsdsd Posted May 5, 2008 Author Share Posted May 5, 2008 all right; that makes sense; I see also that I am going to necessarily have to deal with header( ... ) - something I have always avoided; is there a library of all header values ( other than the php-referenced RFC 2616 (RFC2616) ); // PHP // it seems that I must use something along the lines of header("Content-Type: image/png"); $img = ... imagepng( $img ) ; // ... // but that seems to effect the ability to output html from the same php: echo"<img id='non_dynamic_image' src='...' />" ; thanks dsdsdsdsd Link to comment https://forums.phpfreaks.com/topic/104217-whenwhy-would-a-user-need-to-imagecreatefrompng/#findComment-533563 Share on other sites More sharing options...
roopurt18 Posted May 5, 2008 Share Posted May 5, 2008 Another common use for the image libraries is to confirm that a file is in-fact an image. For example, if you provide an upload script and I rename a php script to have a .jpg extension, depending on how you perform your validation your site may accept my file, even though it is not an image. To validate that the file is actually an image, you might try and open it with the various image manipulation functions; if the functions fail then the file is not a valid image. That said, I use finfo (or fileinfo) for the same functionality. Link to comment https://forums.phpfreaks.com/topic/104217-whenwhy-would-a-user-need-to-imagecreatefrompng/#findComment-533639 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.