pdftk compression option

I had the same problem and found two different solutions (see this thread for more details). Both reduced the size of my uncompressed PDF dramatically. Pixelated (lossy): convert input.pdf -compress Zip output.pdf Unpixelated (lossless, but may display slightly differently): gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH -dQUIET -sOutputFile=output.pdf input.pdf Edit: I just discovered another option (for … Read more

How to reduce the image file size using PIL

A built-in parameter for saving JPEGs and PNGs is optimize. from PIL import Image foo = Image.open(‘path/to/image.jpg’) # My image is a 200×374 jpeg that is 102kb large foo.size # (200, 374) # downsize the image with an ANTIALIAS filter (gives the highest quality) foo = foo.resize((160,300),Image.ANTIALIAS) foo.save(‘path/to/save/image_scaled.jpg’, quality=95) # The saved downsized image size … Read more

How do you Programmatically Download a Webpage in Java

I’d use a decent HTML parser like Jsoup. It’s then as easy as: String html = Jsoup.connect(“http://stackoverflow.com”).get().html(); It handles GZIP and chunked responses and character encoding fully transparently. It offers more advantages as well, like HTML traversing and manipulation by CSS selectors like as jQuery can do. You only have to grab it as Document, … Read more

Gzip versus minify

Very simple to test. I took your js, put them in different files and ran gzip -9 on them. Here’s the result. This was done on a WinXP machine running Cygwin and gzip 1.3.12. -rwx—— 1 xxxxxxxx mkgroup-l-d 88 Apr 30 09:17 expanded.js.gz -rwx—— 1 xxxxxxxx mkgroup-l-d 81 Apr 30 09:18 minified.js.gz Here’s a further … Read more

How does Google’s Page Speed lossless image compression work?

If you’re really interested in the technical details, check out the source code: png_optimizer.cc jpeg_optimizer.cc webp_optimizer.cc For PNG files, they use OptiPNG with some trial-and-error approach // we use these four combinations because different images seem to benefit from // different parameters and this combination of 4 seems to work best for a large // … Read more

How does one make a Zip bomb?

Citing from the Wikipedia page: One example of a Zip bomb is the file 45.1.zip which was 45.1 kilobytes of compressed data, containing nine layers of nested zip files in sets of 10, each bottom layer archive containing a 1.30 gigabyte file for a total of 1.30 exabytes of uncompressed data. So all you need … Read more