Gallery3 jpg conversion module

qtego1

Joined: 2014-07-11
Posts: 6
Posted: Fri, 2014-07-18 18:53

Hello everyone,

I am searching for a module or a way to change any supported image type to jpg on upload to Gallery3. ex; image.png gets changed and uploaded as image.jpg.

Any help would be GREAT!

Thanks,
James Z

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2014-07-19 18:30

I'm not sure about doing it with a module. It would require that you edit the G3 core.
Can't really offer much more than that right now.

I know that GD and ImageMagick are both capable of the conversion, but I'd have to spend time with G3 core to see how it could be accomplished.

 
qtego1

Joined: 2014-07-11
Posts: 6
Posted: Thu, 2014-08-07 14:47

IF I can figure out where the extension of the file attempting to be uploaded is being saved, I believe that I can just hard code it to be .jpg if it matches a typical image extension. Using image_optimizer module will convert them all to jpg properties, but leaves the extension alone.

Our application is looking for the thumbs in each Folder and it needs to be .jpg for the code to read it. Unless we can find a way to look for the thumb and match the image no matter what the extension, that would work too.

 
spags

Joined: 2010-03-26
Posts: 120
Posted: Thu, 2014-08-07 20:41

In ./modules/gallery/models/item.php under the function valid_name, there is some code that performs some checks on the file extension. You might be able to do something similar to identify your "problem" items.

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sun, 2014-08-10 19:15

Working?

 
qtego1

Joined: 2014-07-11
Posts: 6
Posted: Sun, 2014-08-10 20:11

Not yet. Still trying to figure out where and how many places I will need to change to change the image extension to .jpg, or how to get the remote server to find the image with any extension.

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Mon, 2014-08-11 19:36

Your wording is throwing me off a bit. Maybe I'm misunderstanding?

I thought that you were okay with the way G3 uploads/selects images, but wanted the images to be converted and saved as jpg regardless of the original format.

BUT,

qtego1 wrote:
remote server

Where did that come from? You're using serveradd or something?

qtego1 wrote:
find the image with any extension

Is this a separate issue? You're mentioning finding images; I was thinking you wanted to save/convert images.

Either way, you're going to have to do quite a bit of independent study and whatnot (and I may not be able to help much), but, even still, I'm a bit lost as to exactly what you're looking to do.

 
qtego1

Joined: 2014-07-11
Posts: 6
Posted: Mon, 2014-08-11 19:46

Sorry for the confusion. My Gallery issue I'm trying to figure out is to take any image (jpg, jpeg, png, gif) and write them all as jpg only. albums, thumbs, resize folder...everywhere. Basically nothing but jpg will be written.

 
spags

Joined: 2010-03-26
Posts: 120
Posted: Mon, 2014-08-11 22:18

I think what tempg is asking is when would you write them as jpg. At the time the item is uploaded/saved, or when you use a menu/button to run a function to perform the conversion?

By the sounds of it, you mean at the time the item is uploaded/saved. I'm not sure you could actually do that cleanly, but what you could possibly do is hook into the callback for a new item, then use your routines to convert it to jpg temporarily, import that as a new item and then delete the original item. Not very optimal but I suspect it may be more achievable.

On the other hand, maybe there is some way in the callback to convert to jpg at that time and somehow modify the pending new item information to show that it is jpg (which would be a whole lot cleaner).

 
qtego1

Joined: 2014-07-11
Posts: 6
Posted: Mon, 2014-08-11 22:35

I do use the module "image_optimizer" that, from my understanding, strips any image down to .jpg format but leaves the extension as the original. I was hoping to keep using that, and when it uploads the image to the server, find the part that writes and simply hard code the $extension to ."jpg"

Not sure if that is even possible, but that's my current direction....