resize_to_limit greatly increases file size for PNGs

Author: jasonfineCreated Oct 20, 2025Updated Oct 20, 2025

Original file is 1200 x 1200 PNG with transparency. 293 KB

My uploader has a few version definitions to resize the images using resize_to_limit, e.g.

version :sm do
  process :resize_to_limit => [640, nil]
end

version :md do
  process :resize_to_limit => [1024, nil]
end

version :lg do
  process :resize_to_limit => [1400, nil]
end

All of the resulting versions are at least twice the file size of the original.

What's particularly interesting is the lg version. According to the documentation, resize_to_limit should only be resizing the image if it's width is greater than 1400. In this case the file it's producing is still 1200 wide, but file size increases from the original 293 to 917 KB.

Source: carrierwaveuploader/carrierwave