apoorv-2204
We have a service in production where we accept documents from users/clients
mainly: jpeg, png and pdf. And there are several of this file provided by client to fulfill the requirements.
The issues is when these files are needed to be send over email. with email size limit of 25 mb , the mail fails as of SendGrid services
I want to compress the incoming images png jpeg and pdf
But I don't want to loss quality, and they should be at least legible
What should I use what lib?
anything existing in elixir eco
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kip
Images, including jpeg and png, already contain compressed data so I would be surprised if they will compress significantly to get you under the 25mb limit if you’re already over it. I typically find a compressed jpeg/png image is only about 10% smaller than the original image.
apoorv-2204
i have seen that,we can further compress jpeg, and png without losing quality as much
kip
Your original message says “lossless”. Higher jpeg/png compression (ie lower quality) is not lossless. Can you be a bit more specific about your requirements?
dimitarvp
I simply searched for “optimize image api” and drowned in results.
As for lossless / lossy, IMO any image that’s 25MB is way too big. Though I don’t know your scenario, maybe you are working with galactic deep-field assembled images.
mindok
As @kip has mentioned, JPG compression is lossless.
You can experiment with image editors or command line tools to get a sense of what loss you can get away with without breaking the use case, and it highly depends on the type of image. You typically have two variables to play with - image dimensions (i.e. resampling the image to make it smaller - depending on the types of image, some interpolation algorithms can be better than others), and a “quality” parameter. Due to the way JPG compression works, you can generally compress more when you have smooth gradients (e.g. skin tones with shadows), whereas lots of sharp colour changes (e.g. screenshots) tend to look terrible when heavily compressed.
PNG compression can be lossless - it works really well for screenshots where you have big blocks of the same colour. Generally it’s a tradeoff between computation time and compression.
PDF compression is complex - I’d set aside a good week for research and testing if you are going down that path. It can involve things like font stripping, embedded image compression etc, etc. I’ve gone down that rabbit hole and there are no easy answers. There are PDF compression services that can help, but I found nothing I would be happy to embed in my stack.
benwilson512
You’ve got some solid answers in the compression front so I’ll do the other angle: see if you can change the requirement to allow links to files. There’s a reason companies that specialize in document sharing don’t email them, and instead do links.
harrisi
You got PNG and JPEG mixed up here - JPEG is (typically) lossy, PNG is lossless. Good info, though!
kevinschweikert
It should be the other way round. Our eye is much more sensitive for brightness than color changes. If the compression algorithm has to remove information in a gradient we tend to see it. A solid block of color in the other hand is easy to compress because it’s mostly a redundant information. With the contrast changes you are right because the compression algorithm reduces the “frequency” with something called a Discrete Cosine Transform (DCT). But there are more factors in the compression like color subsampling etc
AstonJ
I’ve updated the title though as pointed out by others it is not clear what you are after.
If you don’t want to lose quality then your best bet may be to zip the file and send that - this will not lose quality of the original file. If you compress image files themselves then, as pointed out already, that is lossy compression - however you can use tricks like converting PNGs to jpeg, reducing image size etc.
Also keep in mind many email providers have a limit on incoming email size as well.
apoorv-2204
the image/pdf should be at least bare min legible.
I saw d/f algo like imagemagick ghostscript