Converting Image Formats |
[eluser]cassy[/eluser]
Hey guys, this is my first post here. I'm new to PHP and CI and I love it! :-) As I'm so new, I hope someone can help me. How do I use the Image Manipulation Class to convert between file formats? Lets say I have a .PNG file on my server; how can I convert this to a .JPG format? I'm looking forward to your replies. Thanks. Cassy.
[eluser]vbsaltydog[/eluser]
There are no reformat methods in the class: http://ellislab.com/codeigniter/user-gui...e_lib.html however, since the class does support all three of the major image libraries, you can extend the class and add a reformat method.
[eluser]Jason Stanley[/eluser]
I only had 2 minutes to look at this. The image lib class looks at the extension of the new image config variable. I assume it then outputs the correct image type based on the extension. Have you actually tried setting the $config['new_image'] variable? You could always then unlink the current image to get rid of the duplicate image.
[eluser]Jason Stanley[/eluser]
That sounds like a bug to me. You should log it on GitHub. In the meantime you can either find another library or write something yourself. I would start here: http://www.php.net/manual/en/function.im...rompng.php Then: http://www.php.net/manual/en/function.imagejpeg.php Its super easy.
[eluser]vbsaltydog[/eluser]
Where is your application eventually going to reside? On a Windows Server or a Linux Server? If a Linux Server, you don't want to use a dll and FWIW, most developing is done in a *nix environment.
[eluser]Jason Stanley[/eluser]
Cassy.. what is daunting about the PHP manual? What is so hard about doing doing this!? A + B = C Code: $image = imagecreatefrompng('path/to/image'); To get better you read and experiment. If you can't even be bothered to do that I don't know why you are programming...
[eluser]cassy[/eluser]
@vbsaltydog I'm not sure. I'm doing this to learn so that I can apply to a college next year. I already do web design but I want to be a "Web Developer". My dad said that's where the money is. I don't know much about Linux. I only have access to a Windows 7 computer and am running XAMP + CI. @jason Interesting. Thanks for the Tip. Can you tell me how I can programatically determine if a file is an image and not a, lets say a malicious .PHP file renamed to a .JPG file?
|
Welcome Guest, Not a member yet? Register Sign In |