Save file to jpeg after upload - how does it function?

Just a quick question, this may just me misunderstanding this feature (which i have never actually had reason to use before)

I have a simple file upload

after upload I have a rotate then a file save action, i specify format jpeg and save it with a .jpg extension

I upload a .PNG

This works and both files are displayed, the original as a .png and the rotated version as a .jpg as expected.

image

I now upload a .jpg which uploads as expected

NO ISSUES TO HERE except

I now expect 3 files to be .jpgs and one to be a .png

I now examine the headers of these files in notepad

the .jpg files headers are as expected

ÿØÿà JFIF  ` `  ÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality
ÿÛ C     		


the .png also as expected

‰PNG


However the .jpg created from the .png by the save action indicates it is still actually showing as a .png file in the headers

‰PNG


So my help request is

should the files be converted in format? or
is this just me misunderstanding the feature? or
is this me not properly understanding image file headers? or
is this potentially a bug?

Happy New Year!

It should be converted to an actual jpeg and not be a png with just a .jpg extension in the filename.

Is it NodeJS that you use?

Apologies, this is PHP using Wappler Local server
I really should have specified that.

Please test following update

image.zip (1.7 KB) Unzip to dmxConnectLib/modules

Sorry but header still shows as .png

Here is api action I am using for info

[rotateandmakejpeg.zip|attachment]
(upload://41x5r3riD3fmw9SXyd85binsBL1.zip) (790 Bytes)

I see no obvious reference to image type change in code?

        "name": "newImage",
        "module": "image",
        "action": "save",
        "options": {
          "instance": "image",
          "path": "/assets/images/uploads",
          "template": "{name}_rotated.jpg",
          "overwrite": true
        },
        "output": true

I expected to see a format option?
Could that be where the issue lies?

Done some further checks and can confirm

If selecting any other format, a option like this is added:

          "format": "gif"

If selecting jpeg, it is missing

tried adding "format" : "jpeg" but error is thrown

What is the error you get when adding "format": "jpeg"?

sorry, was out for lunch.

My apologies, the error came from my careless manual entry
( "format:" "jpeg", instead of "format": "jpeg",)

it works using below HJSON so guess issue is missing "format" entry

        "name": "newImage",
        "module": "image",
        "action": "save",
        "options": {
          "instance": "image",
          "path": "/assets/images/uploads",
          "template": "{name}_rotated.jpg",
          "overwrite": true,
          "format": "jpeg",	
          "quality": 75
        },
        "output": true
ÿØÿà JFIF  ` `  ÿþ ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 75
ÿÛ C     		


Seems that the default defined in the extension is wrong, jpeg was the default while the server connect action has auto detect as default. Will fix in a update.

2 Likes

Fixed in the latest extensions updates.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.