Consider the following scenario, Jow Forums:

Consider the following scenario, Jow Forums:

>Have a .jpg file
>You don't know what program it was made with, what compression settings it used or anything
>The file is converted to .png, original file is lost
>The file is now 10 times bigger, but didn't gain any quality
>If you convent it to .jpg again with whatever piece of software you have at hand, it will most likely get re-compressed and lose quality
Does there exist software that would be able to convert a jpg-turned-png back into jpg in a lossless manner?

All I know is that theoretically, it should be possible, but I don't know how difficult it is to find the exact same jpg blocks as were originally created.

Attached: anime jpg.jpg (457x640, 10K)

Also, while I don't know whether finding the exact same JPG is feasible (hence why I'm asking) I did run some tests to figure out whether a re-jpgized file would be identical if it was recreated using the exact same settings.

What I did was:
Using gimp. I took a file, saved it to jpg, then to png, then to jpg again. I used the exact same parameters (90 quality, 0 smoothing, 4:4:4 subsampling) to create and re-create the jpg.

I then ran the original jpg and the re-created jpg through a difference filter, to see how they differ.

First image I used for testing
Original PNG

Attached: 2Original PNG.png (1000x1000, 349K)

First JPG

Attached: 2First JPG.jpg (1000x1000, 39K)

PNG created from this JPG

Attached: 2Second PNG.png (1000x1000, 143K)

and the second JPG, created from this PNG

Attached: 2Second JPG.jpg (1000x1000, 40K)

And a difference matte, amplified about by a factor of a few hundred .
As you can see, just using the original settings (and not explicitly searching for the original patterns) GIMP was able to recreate a very similar JPG image. The majority of the image went completely unaffected, and there were only a handful of distortions, most notably on the cyan-to-magenta gradient.
Interestingly, the pepper in this image went completely untouched.

Attached: 2difference matte.png (1000x1000, 24K)

Here is another image I did the same thing to...

Attached: 3First.jpg (1000x1000, 126K)

and here, all the peppers got equally screwed over, except for the black and white ones.

Attached: 3Matte.png (1000x1000, 96K)

What the fuck are you talking about

Also, just out of curiosity:
here is a comparison between the original PNG and the final JPG.
As expected, it gets absolutely screwed over, but that was to be expected.

Attached: 3png-finaljpg matte.png (1000x1000, 369K)

this is genuinely interesting

also, how high are you right now?

>also, how high are you right now?
two plates of spicy chicken nuggets high

While I'm waiting for somebody else to chime in with any answer or assistance - I couldn't find one myself, either nobody else tried it, or I'm just too stupid and can't type the query properly, which is entirely possible - I've been testing even more images. This time I used an anime girl I grabbed from pixiv, and decided to try out different settings.

Attached: 4original.png (800x889, 739K)

Here is a difference matte for two JPGs exported on 100 Quality setting A lot got lost in rejpgisation

Attached: 4matte100.png (800x889, 71K)

However, here is a difference matte for two JPGs that were exported on 50 Quality setting.
I guess it was a predictable outcome, but nice to observe anayways - the lower the quality setting. the easier it is to re-create the original JPG accurately.

Attached: 4matte50.png (800x889, 7K)

However, that only applies when we know the setting. Here a matte between Original JPG that was exported on 50 Quality, and a Re-created JPG exported on 100 Quality. It actually suffered quite a lot of degradation!

Attached: 4matte50-to100.png (800x889, 78K)

>>The file is converted to .png, original file is lost
What did you do to this poor image, the compression was lossy, set so high. Yuck!

Attached: 1529196240162.jpgXX0001.jpg (1280x1080, 226K)

This is a superior image, see the difference?

Attached: 1529198460106.pngXX0001.jpg (1280x1080, 238K)

For completeness.

Attached: 1529197286324.jpgXX0001.jpg (1280x1080, 267K)

Attached: f19.jpg (277x296, 22K)

>Does there exist software that would be able to convert a jpg-turned-png back into jpg in a lossless manner?
No. In fact I believe any software that could do it would be able to recreate the original lossless, since that's basically what you're asking -- recreate the original PNG and recompress to jpeg, since the jpeg depends on the original PNG.

Attached: 1524576951710.jpg (1142x1600, 171K)

Mate, you don't need to explain the quality superiority of PNGs over JPGs to me, I'm well aware of it.
But not all images have a PNG original. Cheap digital cameras usually automatically store pictures as JPGs. Screencaps from compressed movies are JPGs. And hell, some artists release their works as JPGs only, and keep the raw files to themselves. The visualizations you posted are JPGs.
Point is, you can't always get a PNG image, and converting a JPG into a PNG is pointless - the harm has already been done, data already lost.

So, if you have an "original" JPG file, it's best to keep it exactly as it is.
However, if it accidentally gets turned into a PNG - well, now on top of having an imperfect picture, you are also wasting a ton of drive space. So it would be nice to be able to restore the original JPG without doing too much harm.

Excellent, thanks, user!

Attached: 1529199400753.jpgXX0001.jpg (1280x1080, 231K)

program called JPQ will tell you how much compression was used on any jpeg. works on a 1 - 100% scale with 100% being no compression used. but really opening and closing a jpeg countless times and up scaling it only results in quality loss. can't create detail/pixels from nothing you know. i save all my digital photos as uncompressed tiff. still keep the jpegs though. drive space is cheap, ruining photos by compressing them/degrading the quality is bad. Store them on a refs and zfs drives so barring some freak accident they'll look just as good now in 10/40 yrs from now. a proper photo is 300 dpi at whatever size you need. 300 dpi, no 72 or 100 or 96. if you can't print a 8x10 @ 300dpi then go lower till you can. 4x6 is as low as you can go while retaining a photo size. lots of the pics in /HR can't print a proper 8x10. yes they got high pixel counts but dpi matter more.

>since the jpeg depends on the original PNG.
Not necessarily.
As my tests prove, even basic JPG exporting - without intentionally trying to recreate the original - gets the blocks accurately quite often!

Attached: __oumae_kumiko_hibike_euphonium_drawn_by_nagayori__e31685fb1f4d907ff3b44e0c57729aff.jpg (1142x1600, 138K)

very autistic thread indeed

Nothing wrong with that desu

a 24x36 poster @300 dpi would be 224mb at minimum. 224mb! Tell me, what's the max res /HR will allow again? 7mb. Seems like a lot of quality is getting shat don't it? Quality, it fucking matters. the max google does is 70mp, seems like a lot, but photoshop don't lie. the dpi of a lot of "70mp" images is frankly appalling.

Not being a retarded weeb and freetard would give your work more credibility, OP.

for another test, I took this image, exported it to JPG, then using the same settings, repeatedly edited and overwrote it over and over and over. I did it WITHOUT PNGising it inbetween, though, just editing the JPG and overwriting.
I did it so while adding an increasing black spot in the corner, to ensure that gimp actually overwrites the image, and isn't just checking if the files are identical.

Attached: 5original.png (1000x825, 796K)

multiple overwrites did seem to deteriorate the image - here is a matte between first jpg and like, 20th jpg

Attached: 5matte repeated overwrite degradation.png (1000x825, 22K)

However, interestingly, here is a matte between the 20th and 21st export.
note, that the circle in the corner is because of the overwrite-ensuring-circle I kept adding.
Seems like after a while, the image found some jpg-equilibrium, wherein the blocks kept being perfectly recreated over and over.

Attached: 5two-last-steps matte.png (1000x825, 7K)

Indeed, I also turned it into PNG, then to JPG again, and it remained perfectly unchanged!

Attached: 5 two-last-pngized matte.png (1000x825, 7K)

I'm sorry user, next time I make a thread about image formats I'll make sure to use only Steven Universe Fanart edited in Adobe Photoshop


-Sent from my iPhone

Attached: tumblr_p9rqvy01T.png (1024x512, 382K)

Attached: 1529199686725.jpgXX0001.jpg (1280x1080, 215K)

Attached: 1529200385607.pngXX0001.jpg (1280x1080, 211K)

That post was truly awful. It is painfully obvious that you do not belong here. But that is okay! There is a positive solution. Rather than trying to fit in, you should strongly consider going to a site more suitable for posters like you, such as reddit, tumblr, or maybe even gaia! You have plenty of options. You will be happy, and we will be happy. Best of luck, but don't come back. Bye!

Okay, with some further testing: This is another image in JPG equilibrium.
As long as it is always saved to JPG with
>Quality 100
>0 Smoothing
>Subsampling 4:4:4
>Integer DCT
>Optimized and Progressive enabled
It will stay the exact same image, no further degradation will happen.
Which proves that it is technically possible to have a non-solid-color JPG which is reversible restartable.

Attached: 6first-equilibrium.jpg (600x843, 547K)

Well software should definitely exist but I don't think ImageMagick is that software

Try writing your own libs?

Fuck off

Attached: AnimeBabeImagemagicConv.png (3600x1853, 3.18M)

>save .jpg as a bitmap
>save bitmap as a .png

is it possible to un-conway things back to an original state or is the information thrown away into oblivion with compression??

Who's this bitch?

>reversible restartable
meant to say
>reversibly rasterizable

Here is also a lower quality (50) version also in equilibrium. And unlike the 100 Quality one, which was almost exactly the same size as the PNG, this one is significantly smaller - about 1/10 the size.
The lower quality version reached equilibrium much faster, but there were still blocks that kept changing slightly with every iteration.
I still don't know what types of blocks are in "equilibrium", so I guess I'll be trying to identify them tomorrow.

>Try writing your own libs?
I'm still not sure how difficult it would be. I should be able to relatively easily identify which areas of the picture would remain unaffected by re-jpgification, but as of now, the only idea I have for finding the proper combination of basis functions for the non-equilibrium blocks is brute force.
It would be useful to figure out how many different possible coefficient blocks there are at any quality level. But if I understand the specification right, there will be millions of possible coefficients, so I would need to figure out some effective way of filtering out the unlikely outcomes.

Attached: 6equilibrium50-2.jpg (600x843, 67K)

>back to an original state or is the information thrown away into oblivion with compression
you mean, back to the original bitmap? Before it was ever saved to JPG?
Impossible, information is irreversibly lost. You can erase the artifacts, and make an educated guess as to what the bitmap looked like before being encoded, but you will never restore the original data.

JPEG is a cancer and FLIF is the solution.

yes it is, but until you write to you pal hiroyuki and convince him that he should allow us to upload FLIFs, we're stuck with this

It will look exactly the same, provided you use same compression settings. Jpeg compression doesn't just makes picture worse every time. It converts it to 2d frequency map and ignores frequencies with very low amplitude, i.e. those that don't contribute to the picture, and so some space is saved. If you set it to ignore bigger amplitudes, the image will lose detail but file will be smaller. Viewer then generates image back from frequency map. Now, if you pass into it an image that doesn't contain would-be ignored frequencies, then compression has no visual effect. This is why compressing jpeg again doesn't makes it look worse.

Well unless your dogshit software applies mandatory filters to the image before compression, distorting the frequencies and making jpeg encoder discard more data.

tested it with ImageMagick,
tested it with GIMP (whatever JPEG encoder it uses)
Pic related is tested with Adobe Photoshop.
What "not dogshit software" would you recommend?

Attached: Matte.png (700x741, 134K)

Well gee I dunno, all I know is that jpeg compressor doesn't naturally does that crap. Maybe the decoder applies sharpen filter when it loads a jpeg, maybe the encoder applies it immediately before saving.

And here is tested with Krita

Oh, unless you literally mean "the difference is is there, but not visible to the naked eye at 100% zoom level", in which case - you're in the wrong place bucko, we have audiophiles here who only listen to music in FLAK, do you really think we're going to let those few valuable pixels get distorted?
Well the answer is probably "yes, when we realize it's impossible not to", but we will still stubbornly try.

Attached: 7Matte.png (700x884, 87K)

I am unironically, unsarcastically, unfecetiously asking: Could you please a clean, not "enhanced" in any way, implementation of a JPG encoder?
I am fully willing to believe that you are right, and that all image editing software simply tacks on some extra "feature" that makes the image appear visually better, but distorts the actual data. But I would like to test it for myself.

>Could you please a clean
Well I imagine you could, cleans are easily pleasable, but I meant to say
>please provide

No. You will have to shop around. Thankfully there are shit ton of open source jpeg libraries, so even if you never find exact one, you can modify one of many into that state.

>this thing is perfect, it makes no mistakes
>if I makes mistakes, that means it's shit software
>w-what? Provide a working example? Oh fuck off, it's not my business!
Do you also run GNU+HURD?

Use imagemagick from the command line so you can automate this shit.

Also use waifu 2x to upscale images and remove jpeg artifacts.

> Does there exist software that would be able to convert a jpg-turned-png back into jpg in a lossless manner?


No. The reason is that there is also a colorspace conversion done in addition to the cosine transform. PNG is done in RGB, where JPG is done in luma + chroma channels.

Mostly correct. The cosine+decimation transform is a 2d low-pass filter which removes signal above a certain frequency. Applying it more than once can't remove data that isn't there.

t. a jpeg decoder author.

>that theoretically, it should be possible
No, it isn't possible.

No, as the data used to compress the image is lost once converting it to png. JPGs aren't actually images, they're decompression algorithms.