What's new

Is it possible to add a canvas to a jpeg without recompressing it?


winterludes

Member
Messages
7
Likes
0
I've got a whole bunch of web ready jpegs, and many of them I've lost the original full size images due to one loss of data I can't explain, don't know how it happened. Anyways, I'm building a new website and the gallery I'm using is really great and I've spent a lot of time as well as some money with a web designer making it work really well, except I've just found out it only accepts maximum widths to constrain the image from just expanding to fill the page. Apparently this is something that's difficult with this kind of image gallery as far as the coding goes.

It's ok for my square Hasselblad images. But I've also got some galleries of digital images with some verticals, and I don't have the orignal files of many of them. I size them so they are all 550px tall so the height isn't jumping all around. But verticals means the width changes, and this image gallery enlarges the vertical images to fill up to the set width, which makes them look terrible not to mention the jarring effect of enlarging and then going back.

So my question is whether there is a way to add a canvas to a jpeg to widen the verticals to the same width as the horizontals, without re-compressing them? I found a neat plugin for Lightroom that adds canvas to images in the export process, but it won't work if I select "orginal" in the file type. I've emailed them about possibly fixing this, but haven't heard back yet.

Is there a way? Below is an example vertical image with the canvas applied. This one was recompressed though by Lightroom.

Mod edit: Please review the rules about posting images directly to the forum.
IlyyeYE.jpeg
 

Argos

Guru
Messages
2,953
Likes
4,381
English is not my native language so I usually leave this complicated text to other users, because it's highly probable that I misunderstood something:joy: but is this what you need?

Picture.jpg
 

thebestcpu

Guru
Messages
1,459
Likes
1,265
Hi winterludes
There is one option that should work and another to explore
1) Web browsers support PNG files. File can be read in as JPEG, extra canvas added and then saved as a PNG-24 with no loss of information. The file size will be slightly larger yet absolutely no loss of information.
2) Resaving a JPEG at maximum quality would be about 1/2 the size of the PNG with probably imperceptible losses
3) There are some programs that do lossless recompression yet there are specific limitations and not sure they can add canvas. The specific program with which I am familiar is JPEGTRAN. Here is a link to the library that contains this function: https://en.wikipedia.org/wiki/Libjpeg#cite_note-jpegtran-5

Hope this helps some
John Wheeler
 

thebestcpu

Guru
Messages
1,459
Likes
1,265
Hi rhythmdevils
Here is a program that claims to be able to add margins without loss to a JPEG image. I have not used it yet I suspect to get no losses I suspect that the image will have to line up on the 8 pixel bit block boundaries. It has a free trial so hope this solves your question.

https://www.betterjpeg.com/

John Wheeler
 

Top