fewlaps / slim-jpg Goto Github PK
View Code? Open in Web Editor NEW๐ค Optimize your JPGs on the fly
๐ค Optimize your JPGs on the fly
In our tests, if you convert a very optimized PNG, the JPG will be bigger. So, our algorithm, right now, converts that perfect PNGs to JPGs with quality 0%. So sad.
Hello, thank you very much for the contribution, it would be good to be published in central maen
/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -javaagent:/opt/idea-IU-192.7142.36/lib/idea_rt.jar=37587:/opt/idea-IU-192.7142.36/bin -Dfile.encoding=UTF-8 -classpath /home/jibarra/Documents/projects/mexperiencia/mexperiencia_backend/module-ebs/target/classes:/home/jibarra/Documents/projects/mexperiencia/mexperiencia_backend/module-core/target/classes:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.1.4.RELEASE/spring-boot-starter-web-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.1.4.RELEASE/spring-boot-starter-json-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.8/jackson-datatype-jdk8-2.9.8.jar:/home/jibarra/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.8/jackson-datatype-jsr310-2.9.8.jar:/home/jibarra/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.8/jackson-module-parameter-names-2.9.8.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.1.4.RELEASE/spring-boot-starter-tomcat-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.17/tomcat-embed-core-9.0.17.jar:/home/jibarra/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.17/tomcat-embed-el-9.0.17.jar:/home/jibarra/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.17/tomcat-embed-websocket-9.0.17.jar:/home/jibarra/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.16.Final/hibernate-validator-6.0.16.Final.jar:/home/jibarra/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/home/jibarra/.m2/repository/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/home/jibarra/.m2/repository/org/springframework/spring-web/5.1.6.RELEASE/spring-web-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-webmvc/5.1.6.RELEASE/spring-webmvc-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-expression/5.1.6.RELEASE/spring-expression-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-security/2.1.4.RELEASE/spring-boot-starter-security-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-aop/5.1.6.RELEASE/spring-aop-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/security/spring-security-config/5.1.5.RELEASE/spring-security-config-5.1.5.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/security/spring-security-core/5.1.5.RELEASE/spring-security-core-5.1.5.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/security/spring-security-web/5.1.5.RELEASE/spring-security-web-5.1.5.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-data-mongodb-reactive/2.1.4.RELEASE/spring-boot-starter-data-mongodb-reactive-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/data/spring-data-mongodb/2.1.6.RELEASE/spring-data-mongodb-2.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-tx/5.1.6.RELEASE/spring-tx-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/data/spring-data-commons/2.1.6.RELEASE/spring-data-commons-2.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/mongodb/mongodb-driver/3.8.2/mongodb-driver-3.8.2.jar:/home/jibarra/.m2/repository/org/mongodb/bson/3.8.2/bson-3.8.2.jar:/home/jibarra/.m2/repository/org/mongodb/mongodb-driver-core/3.8.2/mongodb-driver-core-3.8.2.jar:/home/jibarra/.m2/repository/org/mongodb/mongodb-driver-async/3.8.2/mongodb-driver-async-3.8.2.jar:/home/jibarra/.m2/repository/org/mongodb/mongodb-driver-reactivestreams/1.9.2/mongodb-driver-reactivestreams-1.9.2.jar:/home/jibarra/.m2/repository/org/reactivestreams/reactive-streams/1.0.2/reactive-streams-1.0.2.jar:/home/jibarra/.m2/repository/io/projectreactor/reactor-core/3.2.8.RELEASE/reactor-core-3.2.8.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-data-redis/2.1.4.RELEASE/spring-boot-starter-data-redis-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/data/spring-data-redis/2.1.6.RELEASE/spring-data-redis-2.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/data/spring-data-keyvalue/2.1.6.RELEASE/spring-data-keyvalue-2.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-oxm/5.1.6.RELEASE/spring-oxm-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/io/lettuce/lettuce-core/5.1.6.RELEASE/lettuce-core-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/io/netty/netty-common/4.1.34.Final/netty-common-4.1.34.Final.jar:/home/jibarra/.m2/repository/io/netty/netty-handler/4.1.34.Final/netty-handler-4.1.34.Final.jar:/home/jibarra/.m2/repository/io/netty/netty-buffer/4.1.34.Final/netty-buffer-4.1.34.Final.jar:/home/jibarra/.m2/repository/io/netty/netty-codec/4.1.34.Final/netty-codec-4.1.34.Final.jar:/home/jibarra/.m2/repository/io/netty/netty-transport/4.1.34.Final/netty-transport-4.1.34.Final.jar:/home/jibarra/.m2/repository/io/netty/netty-resolver/4.1.34.Final/netty-resolver-4.1.34.Final.jar:/home/jibarra/.m2/repository/redis/clients/jedis/2.9.3/jedis-2.9.3.jar:/home/jibarra/.m2/repository/org/slf4j/slf4j-api/1.7.26/slf4j-api-1.7.26.jar:/home/jibarra/.m2/repository/org/apache/commons/commons-pool2/2.6.1/commons-pool2-2.6.1.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.1.4.RELEASE/spring-boot-starter-actuator-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.1.4.RELEASE/spring-boot-actuator-autoconfigure-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-actuator/2.1.4.RELEASE/spring-boot-actuator-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/io/micrometer/micrometer-core/1.1.4/micrometer-core-1.1.4.jar:/home/jibarra/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.9/HdrHistogram-2.1.9.jar:/home/jibarra/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar:/home/jibarra/.m2/repository/io/micrometer/micrometer-registry-prometheus/1.1.4/micrometer-registry-prometheus-1.1.4.jar:/home/jibarra/.m2/repository/io/prometheus/simpleclient_common/0.5.0/simpleclient_common-0.5.0.jar:/home/jibarra/.m2/repository/io/dropwizard/metrics/metrics-graphite/4.0.5/metrics-graphite-4.0.5.jar:/home/jibarra/.m2/repository/io/dropwizard/metrics/metrics-core/4.0.5/metrics-core-4.0.5.jar:/home/jibarra/.m2/repository/com/rabbitmq/amqp-client/5.4.3/amqp-client-5.4.3.jar:/home/jibarra/.m2/repository/io/dropwizard/metrics/metrics-jvm/4.0.5/metrics-jvm-4.0.5.jar:/home/jibarra/.m2/repository/io/prometheus/simpleclient_dropwizard/0.6.0/simpleclient_dropwizard-0.6.0.jar:/home/jibarra/.m2/repository/io/prometheus/simpleclient/0.6.0/simpleclient-0.6.0.jar:/home/jibarra/.m2/repository/com/googlecode/libphonenumber/libphonenumber/8.10.11/libphonenumber-8.10.11.jar:/home/jibarra/.m2/repository/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar:/home/jibarra/.m2/repository/com/auth0/java-jwt/3.7.0/java-jwt-3.7.0.jar:/home/jibarra/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.8/jackson-databind-2.9.8.jar:/home/jibarra/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/home/jibarra/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.8/jackson-core-2.9.8.jar:/home/jibarra/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:/home/jibarra/.m2/repository/io/springfox/springfox-swagger2/3.0.0-SNAPSHOT/springfox-swagger2-3.0.0-20190808.104142-39.jar:/home/jibarra/.m2/repository/io/swagger/swagger-annotations/1.5.20/swagger-annotations-1.5.20.jar:/home/jibarra/.m2/repository/io/swagger/swagger-models/1.5.20/swagger-models-1.5.20.jar:/home/jibarra/.m2/repository/io/springfox/springfox-spi/3.0.0-SNAPSHOT/springfox-spi-3.0.0-20190808.104142-39.jar:/home/jibarra/.m2/repository/io/springfox/springfox-core/3.0.0-SNAPSHOT/springfox-core-3.0.0-20190808.104142-39.jar:/home/jibarra/.m2/repository/io/springfox/springfox-schema/3.0.0-SNAPSHOT/springfox-schema-3.0.0-20190808.104142-39.jar:/home/jibarra/.m2/repository/io/springfox/springfox-swagger-common/3.0.0-SNAPSHOT/springfox-swagger-common-3.0.0-20190808.104142-39.jar:/home/jibarra/.m2/repository/io/springfox/springfox-spring-web/3.0.0-SNAPSHOT/springfox-spring-web-3.0.0-20190808.104142-38.jar:/home/jibarra/.m2/repository/io/github/classgraph/classgraph/4.1.7/classgraph-4.1.7.jar:/home/jibarra/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/home/jibarra/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE.jar:/home/jibarra/.m2/repository/org/mapstruct/mapstruct/1.3.0.Final/mapstruct-1.3.0.Final.jar:/home/jibarra/.m2/repository/io/springfox/springfox-swagger-ui/3.0.0-SNAPSHOT/springfox-swagger-ui-3.0.0-20190808.104142-39.jar:/home/jibarra/.m2/repository/io/springfox/springfox-spring-webmvc/3.0.0-SNAPSHOT/springfox-spring-webmvc-3.0.0-20190808.104142-31.jar:/home/jibarra/.m2/repository/joda-time/joda-time/2.10.1/joda-time-2.10.1.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-mail/2.1.4.RELEASE/spring-boot-starter-mail-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-context-support/5.1.6.RELEASE/spring-context-support-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-beans/5.1.6.RELEASE/spring-beans-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-context/5.1.6.RELEASE/spring-context-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/com/sun/mail/javax.mail/1.6.2/javax.mail-1.6.2.jar:/home/jibarra/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-thymeleaf/2.1.4.RELEASE/spring-boot-starter-thymeleaf-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/thymeleaf/thymeleaf-spring5/3.0.11.RELEASE/thymeleaf-spring5-3.0.11.RELEASE.jar:/home/jibarra/.m2/repository/org/thymeleaf/thymeleaf/3.0.11.RELEASE/thymeleaf-3.0.11.RELEASE.jar:/home/jibarra/.m2/repository/org/attoparser/attoparser/2.0.5.RELEASE/attoparser-2.0.5.RELEASE.jar:/home/jibarra/.m2/repository/org/unbescape/unbescape/1.1.6.RELEASE/unbescape-1.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/thymeleaf/extras/thymeleaf-extras-java8time/3.0.4.RELEASE/thymeleaf-extras-java8time-3.0.4.RELEASE.jar:/home/jibarra/.m2/repository/com/amazonaws/aws-java-sdk-pinpointemail/1.11.534/aws-java-sdk-pinpointemail-1.11.534.jar:/home/jibarra/.m2/repository/com/amazonaws/aws-java-sdk-core/1.11.534/aws-java-sdk-core-1.11.534.jar:/home/jibarra/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/jibarra/.m2/repository/org/apache/httpcomponents/httpclient/4.5.8/httpclient-4.5.8.jar:/home/jibarra/.m2/repository/org/apache/httpcomponents/httpcore/4.4.11/httpcore-4.4.11.jar:/home/jibarra/.m2/repository/software/amazon/ion/ion-java/1.0.2/ion-java-1.0.2.jar:/home/jibarra/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.9.8/jackson-dataformat-cbor-2.9.8.jar:/home/jibarra/.m2/repository/com/amazonaws/jmespath-java/1.11.534/jmespath-java-1.11.534.jar:/home/jibarra/.m2/repository/com/amazonaws/aws-java-sdk-s3/1.11.534/aws-java-sdk-s3-1.11.534.jar:/home/jibarra/.m2/repository/com/amazonaws/aws-java-sdk-kms/1.11.534/aws-java-sdk-kms-1.11.534.jar:/home/jibarra/.m2/repository/com/stripe/stripe-java/10.7.0/stripe-java-10.7.0.jar:/home/jibarra/.m2/repository/com/github/depsypher/pngtastic/1.5/pngtastic-1.5.jar:/home/jibarra/.m2/repository/com/fewlaps/slimjpg/slimjpg/1.3.3/slimjpg-1.3.3.jar:/home/jibarra/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.2.71/kotlin-stdlib-jdk8-1.2.71.jar:/home/jibarra/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.2.71/kotlin-stdlib-jdk7-1.2.71.jar:/home/jibarra/.m2/repository/com/twelvemonkeys/imageio/imageio-jpeg/3.4.2/imageio-jpeg-3.4.2.jar:/home/jibarra/.m2/repository/com/twelvemonkeys/imageio/imageio-core/3.4.2/imageio-core-3.4.2.jar:/home/jibarra/.m2/repository/com/twelvemonkeys/imageio/imageio-metadata/3.4.2/imageio-metadata-3.4.2.jar:/home/jibarra/.m2/repository/com/twelvemonkeys/common/common-lang/3.4.2/common-lang-3.4.2.jar:/home/jibarra/.m2/repository/com/twelvemonkeys/common/common-io/3.4.2/common-io-3.4.2.jar:/home/jibarra/.m2/repository/com/twelvemonkeys/common/common-image/3.4.2/common-image-3.4.2.jar:/home/jibarra/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.2.71/kotlin-stdlib-1.2.71.jar:/home/jibarra/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.2.71/kotlin-stdlib-common-1.2.71.jar:/home/jibarra/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter/2.1.4.RELEASE/spring-boot-starter-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot/2.1.4.RELEASE/spring-boot-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.4.RELEASE/spring-boot-autoconfigure-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.1.4.RELEASE/spring-boot-starter-logging-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/home/jibarra/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/home/jibarra/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.11.2/log4j-to-slf4j-2.11.2.jar:/home/jibarra/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar:/home/jibarra/.m2/repository/org/slf4j/jul-to-slf4j/1.7.26/jul-to-slf4j-1.7.26.jar:/home/jibarra/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/home/jibarra/.m2/repository/org/springframework/spring-core/5.1.6.RELEASE/spring-core-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/springframework/spring-jcl/5.1.6.RELEASE/spring-jcl-5.1.6.RELEASE.jar:/home/jibarra/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar:/home/jibarra/.m2/repository/org/springframework/boot/spring-boot-devtools/2.1.4.RELEASE/spring-boot-devtools-2.1.4.RELEASE.jar:/home/jibarra/.m2/repository/org/projectlombok/lombok/1.18.6/lombok-1.18.6.jar:/home/jibarra/.m2/repository/net/bytebuddy/byte-buddy/1.9.12/byte-buddy-1.9.12.jar com.mexperiencia.ebs.Test
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/coroutines/jvm/internal/SuspendLambda
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.fewlaps.slimjpg.core.JpegOptimizer.optimize(JpegOptimizer.kt:24)
at com.fewlaps.slimjpg.RequestCreator.optimize(RequestCreator.kt:13)
at com.mexperiencia.ebs.Test.main(Test.java:24)
Caused by: java.lang.ClassNotFoundException: kotlin.coroutines.jvm.internal.SuspendLambda
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 12 more
OpenJDK Runtime Environment (build 11.0.5-ea+10-post-Ubuntu-0ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.5-ea+10-post-Ubuntu-0ubuntu1, mixed mode, sharing)
Right now, if the JPEG quality applied should be 100% and the resulting file is bigger than the original one, the easy thing to do would be just returning the original file. But if the user requested the library to remove the metadata, it wouldn't be possible, because the original file could have it... so we should have to apply the 100% compression just to remove the metadata. Fail.
Thinking like a user of the library, I would like to just ignore the metadata, removing it or not but having in mind that I want the smaller possible file.
In some rare cases (I've been using this for almost two years and it's the first time I've seen it) an image will get flipped upside down after optimization.
This image will do it https://drive.google.com/file/d/1Ye_PtJga0AHRJ8oQykAFdPQljdRkQiN7/view?usp=sharing with the following settings but other settings produce the result as well.
Result result = SlimJpg.file(inputStream)
.maxVisualDiff(0.5)
.maxFileWeightInKB(1500)
.deleteMetadata()
.optimize();
I also wanted to try it on the website https://slimjpg.herokuapp.com but I always get a 500 with that image
Think how to manage a picture that the user requested to delete the metadata and have a 0.0% difference, where the source was very optimized.
Check a comment in testAvatar
that marks a line with This image is huge because it saves the metadata
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.