| 41 | [[CollapsibleStart(Image Compressor (bash))]] |
| 42 | |
| 43 | * Utilizes ghost script. |
| 44 | * Takes an image and compresses it. Good for larger vector images. |
| 45 | * [https://barmaidsamass.wordpress.com/2015/03/26/bash-script-w-gs-compressing-pdfs/ Wrote a blog post on it for shits and giggles]. |
| 46 | |
| 47 | {{{ |
| 48 | #!/bin/bash |
| 49 | #Script compressor.sh |
| 50 | |
| 51 | files=$@ |
| 52 | |
| 53 | if [ "$files" == "" ]; |
| 54 | then |
| 55 | echo "Error: No files specified, dude." |
| 56 | exit |
| 57 | fi |
| 58 | |
| 59 | for i in $files; |
| 60 | do |
| 61 | echo \"$i\" |
| 62 | gs \ |
| 63 | -o "${i%.pdf}-comp.pdf" \ |
| 64 | -sDEVICE=pdfwrite \ |
| 65 | -dColorConversionStrategy=/LeaveColorUnchanged \ |
| 66 | -dColorsampleMonoImages=false \ |
| 67 | -dColorsampleGrayImages=false \ |
| 68 | -dColorsampleColorImages=false \ |
| 69 | -dAutoFilterColorImages=false \ |
| 70 | -dAutoFilterGrayImages=false \ |
| 71 | -dColorImageFilter=/FlateEncode \ |
| 72 | -dGrayImageFilter=/FlateEncode \ |
| 73 | "${i}" |
| 74 | done |
| 75 | }}} |
| 76 | [[CollapsibleEnd]] |
| 77 | |
| 78 | |