Comments (19)
Hurts me too - I'd have expected no artefacts at quality 100.
BTW, is there some "uncompressed" saving of JPEGs? I'd need them only as mjpeg stream for ffmpeg, any saved CPU load would be welcome.
Originally posted by phmarek (phmarek) on May 28 2012 via Bitbucket
from libgd.
afair jpeg8 and later offers lossless compression.
I did not test yet if the 100 quality goes lossless or if we need an extra option.
Originally posted by pierrejoye (Pierre Joye) on Apr 16 2013 via Bitbucket
from libgd.
The demo page ( http://oserv.org/bugs/gd/ ) now works again, I re-uploaded it.
Please take a look.
Originally posted by ChALkeR (ChALkeR) on Aug 05 2013 via Bitbucket
from libgd.
Hi here =). I am the original issue reporter.
from libgd.
The issue is still valid as of libgd 2.1.1.
from libgd.
if you could attach a small testcase, it would help
from libgd.
@vapier
Testcase:
<?php
$image = imagecreatefrompng('test1.png');
header('Content-Type: image/jpeg');
imagejpeg($image, null, 100);
test1.png: http://oserv.org/bugs/gd/test1.png or http://oserv.org/bugs/gd/test.png
from libgd.
I am not sure what we can change here without providing full tables customization. We simply pass the value to jpeg_set_quality.
And you are right too, current jpeg support does not provide lossless write support.
Which command line or code did you use for imagick? Imagemagick does a lot of magics depending on the arguments :)
from libgd.
convert test1.png default.jpg
convert test1.png -quality 100 100.jpg
convert test1.png -quality 90 90.jpg
Any of those are better than gd with quality 100.
from libgd.
On -quality 89
imagemagick starts too look like libgd with quality 100.
from libgd.
comparing the convert -debug all -vvv
logs, the difference seems to be:
- Sampling factors: 1x1,1x1,1x1 # -quality 100
+ Sampling factors: 2x2,1x1,1x1 # -quality 89
and when i make a similar change to gd_jpeg.c
, the quality improves:
jpeg_set_defaults(&cinfo);
+ cinfo.comp_info[0].h_samp_factor = 1;
+ cinfo.comp_info[0].v_samp_factor = 1;
guess we should use the algos in imagemagick's jpeg.c to figure out what samp factors to use ?
from libgd.
The 1st one (q=100) could be done easily but may drastically increase the file size by default as you can see with the images in this report.
This special case is also very particular as it uses anti-aliasing text patterns which per se are impossible hard to compress nicely from a visual point of view.
The default sampling factor in recent libjpeg (turbo) targets photographies more than text or patterns. PNG fits better for that.
One thing I like to add for 2.3 is to expose the parameters for Codecs like jpeg or PNG. Can be handy.
from libgd.
i think a good trade off is to set the scale factor to 1x1 when quality is >= 90, otherwise let jpeg do its default (2x2).
i agree that exposing the lower API makes sense. let's split that into a new issue though ?
from libgd.
--- a/src/gd_jpeg.c
+++ b/src/gd_jpeg.c
@@ -307,6 +307,10 @@
if(quality >= 0) {
jpeg_set_quality(&cinfo, quality, TRUE);
+ if (quality >= 90) {
+ cinfo.comp_info[0].h_samp_factor = 1;
+ cinfo.comp_info[0].v_samp_factor = 1;
+ }
}
/* If user requests interlace, translate that to progressive JPEG */
should do it.
I will apply + test tomorrow.
from libgd.
lgtm!
from libgd.
our 4th oldest issue closed out! :D
from libgd.
:)
Also fixed the test to get the actual diff.
I will also try to add a better perceptual diff for the tests suite. The current is rather useless without threshold for these cases.
from libgd.
Thanks!
from libgd.
@vapier Thanks for fixing the makefile :)
And as reference for future readers or doc about sampling http://www.impulseadventure.com/photo/chroma-subsampling.html
from libgd.
Related Issues (20)
- create Image from RGBA buffer HOT 2
- Binary Backup compatibility comment in gdImageStruct HOT 3
- Windows MSVC build issue on gd_webp.c HOT 5
- Missing libgd when building gem native extension HOT 2
- gdImageSetInterpolationMethod ignores GD_BICUBIC* HOT 3
- CMake: Inconsistent feature control HOT 9
- [DOC] cmake build dir HOT 4
- .saveAlphaFlag ignored when saving WebP or AVIF HOT 1
- gdImageClone crashes when cloning an instance that filled polygon HOT 2
- test-suite.log FAIL 3 HOT 5
- imageresolution Return incorrect DPI HOT 1
- Is libgd.so.3 backward compatible with libgd.so.2 HOT 4
- Getting Issue With Nirmala UI Font [ Character Issue ] HOT 2
- `imageaffine()` does not seem to work correctly on GD 2.3.3 on an older PHP
- Linker error [Undefined symbols for architecture arm64/M1]!
- Any plan about a new release?
- Support libavif 1.0 in CMake build HOT 5
- Is libgd affected by CVE-2023-4863? HOT 2
- Support for .ico image format HOT 1
- Win64 static build - undefined ref in project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libgd.