Welcome Guest, Not a member yet? Register   Sign In
Saving a PNG as JPG
#1

[eluser]meridimus[/eluser]
Hey guys,

Sort of introduction to the question

I've been using CI to develop little projects and so far I'm really loving it, choosing to use it only for small projects right now but soon I will be using it for a bigger project.

Anyway, currently I have been using jingproject as a little capture tool (it automatically uploads straight to FTP after crops have been made). Point is, it only does this in PNG format.

I have made a website (llllost.com) that is like an image blog for all the images I grab with jing (along with my gf and my brother who also upload to the same place) but obviously most of the images would be much smaller as a jpg.

The question

If I just replace the png extension to jpg will it convert it to a jpg file since I can't see any option for it (or anything in the user guide).
#2

[eluser]Michael Wales[/eluser]
Absolutely not - it will still be a PNG file as that's what the headers of the file say (which tell the operating system how to load that particular file). You can't rename a .txt file to .avi and expect the words to fly across the screen ala "Star Wars."

There currently is no functionality built into CodeIgniter, that I know of, to handle this conversion (unless the library parses the new_image setting and determines your intended filetype based on the extension - I doubt that). imagecreatefrompng() and imagejpeg() would be the places to hit in creating your own library (or extending the image lib).
#3

[eluser]meridimus[/eluser]
Well, since the functionality wasn't documented I assumed that's how the developers thought people would do a conversion. I'll try it tonight, if it's not there I will extend the Image Manipulation class to have it and share it with you guys since it's a pretty important part of image manipulation in my book!

And... of course I know that if I rename a txt file to avi I'm not going to be watching a film anytime soon. I'm not an idiot.
#4

[eluser]Michael Wales[/eluser]
Haha - I didn't mean to insinuate that at all, it was more a joke than anything.

After rereading your post though, I think I misinterpreted what you were meaning. I think you were referring to setting a different extensions within the new_image parameter. To be honest, this would be worth a try - I don't have the framework here at work or I would dive into the code and look for you really quick.
#5

[eluser]Jim Higgins[/eluser]
I know this post is a bit old, but I was wondering if anyone ever resolved this? Is there a way to convert the file type using the existing image manipulation class?




Theme © iAndrew 2016 - Forum software by © MyBB