How to compress a pdf with images - pdf

I'm trying to compress a 30 Mb pdf file which contains scanned text book
i want to reduce the size to something less than 10 MB.
i tried many software like ghost script , Scribus , gimp , Inkscape and more
but no hope
any idea get appreciated .

Related

Why can't I convert certain TIF files that I received in a split archive?

I received a large number of document files, where each document has its own split archive for each page (i.e. file1.001,file1.002,file2.001,file3.001). These are meant to be TIF files that can easily be combined and converted into PDF documents.
However, some of these files will not convert through imagemagick. Some can simply be converted using a different program, which works fine. There are some files where this doesn't work. I tried converting them to .jpg, then to tif, but they won't convert to .jpg. Things got weird when I converted them to .png, as some of these files would have multiple output files associated with them.
This is hard to explain, but I'll try and give an example; file1.001 and file1.002 both have the same image present on them when converted to tif and opened. However, when either of the tif documents is converted to a .png, two .png files are created. One has the original page, but the other one has a second page of the document that I could not view previously.
What could be causing this weird behavior, and how can I convert these to pdf more reliably?
I also used BlueBeam Staple to convert the files, if that helps at all.
Edit:
I've verified I'm on the latest imagemagick release, and I've been using it through PHP to process files. I'm running Windows 10.
Also, here's some example files to play around with. The first TIF actually shows the second page, instead of the page I normally see when I open the file.
Edit 2: Sorry, I thought uploading the image would preserve the file type. Here's a link to some test samples
When I convert your tiff to png, I get two files using IM 7.1.0-10 Q16-HDRI or IM 6.9.12-25 Q16 both on Mac OSX Sierra.
magick -quiet 294944.tif x.png
Produces:
and
Is this not what you get or expect?
P.S.
What are the other two files: 327924.001 327924.002
If those are some kind of split tiff, then it does not look like libtiff, which Imagemagick uses to read TIFFs can handle them. I get errors when attempting to use identify on them.
You definitely have some issue with whatever attempted to write those tiffs.
instrument 294944 page 1 of 2 = G4 199 dpi sheet 2 of 2 294944.tif (25.17 x 17.53 inches)
instrument 294944 page 2 of 2 = G4 199 dpi sheet 1 of 2 294944.tif (24.12 x 17.63 inches)
instrument 327501 page 1 of 1 = UN 72 dpi sheet 1 of 1 327924.001 (124.78 x 93.86 inches)
instrument 327924 page 1 of 2 = G4 400 dpi sheet 1 of 2 327924.002 (23.80 x 17.53 inches)
instrument 327924 page 2 of 2 = G4 400 dpi sheet 2 of 2 327924.002 (23.84 x 17.41 inches)
Two are identified as CCITT Group 4 Fax Encoding which is common for TIFFs of this type.
Tiff is a multi image format so a multipage FAX can be viewed as one file or 4 different printing CMYK colour plates could be sent as one image file for either overlay as one check print or printed one at a time for quality inking.
The file name Tif (or tiff) is usually applied to files with one or more pages (even 400+ for a long novel)
The extension part001.tif part002.tif is usually applied to groups of multiple pages OR for single sequential pages part1.001.tif part1.002.tif
Unfortunately for you you have a mix following a convention that seems to indicate number of pages 002 = 2 pages, but in inconsistent order, so need to check which were used for each file, as there is uncertainty.
Also the internal number does NOT always reflect the filename? perhaps transfer of interest ?
IN ADDITION you have a mix of compression methods and resolution thus cannot be sure of correct scale to be applied.
The best way to resolve this issue is decide how you wish them to be regrouped/sequenced and use the correct scale for each page or group of pages then recombine as desired into PDF.
It would help for a large number to tabulate the pages by number scale size compression etc and then process in identical groups before reorder and merge.

Maximum near-lossless compression via dcm2dcm

I have uncompressed CT DICOM files and using dcm2dcm to compress lossless image from ~500KB to ~120KB:
dcm2dcm --j2kr src.dcm dest.dcm
I wish to push the compression much futher, it must be lossy compression but like near-lossless using but dont know which is the best encodingRate. My goal is to compress ~500KB to <50KB:
dcm2dcm --j2ki -Q [encodingRate] src.dcm dest.dcm
In Oviyam viewer, they made it down to 20KB-30KB JPEG and the image quality is quite well.

Batch extract Hex colour from images to file

I have around 10k images that I need to get the Hex colour from for each one. I can obviously do this manually with PS or other tools but I'm looking for a solution that would ideally:
Run against a folder full of JPG images.
Extract the Hex from dead center of the image.
Output the result to a text file, ideally a CSV, containing the file name and the resulting Hex code on each row.
Can anyone suggest something that will save my sanity please? Cheers!
I would suggest ImageMagick which is installed on most Linux distros and is available for OSX (via homebrew) and Windows.
So, just at the command-line, in a directory full of JPG images, you could run this:
convert *.jpg -gravity center -crop 1x1+0+0 -format "%f,%[fx:int(mean.r*255)],%[fx:int(mean.g*255)],%[fx:int(mean.b*255)]\n" info:
Sample Output
a.png,127,0,128
b.jpg,127,0,129
b.png,255,0,0
Notes:
If you have more files in a directory than your shell can glob, you may be better of letting ImageMagick do the globbing internally, rather than using the shell, with:
convert '*.jpg' ...
If your files are large, you may better off doing them one at a time in a loop rather than loading them all into memory:
for f in *.jpg; do convert "$f" ....... ; done

imagemagick resize - multiple files with wrong filenames after resizing .jpg images

imagemagick resize - multiple files with wrong filenames after resizing .jpg images
Ubuntu 14.04 and ImageMagick 6.7.7-10
I need to resize ~900 jpg images (kept in several folders) to several dimensions, with the current aspect ratio. I wished to start with 300px wide versions.
I selected the first folder 1997 and I typed convert '*.jpg[300x]' *.jpg and the task was successful.
I have 98 jpg files resized to 300px wide (and no large files as they have been overwritten.)
I switched to the second folder 1998 and I typed in the same convert '*.jpg[300x]' *.jpg
( I also tried with convert *.jpg -resize 300 *.jpg, with the same result. )
Unexpected result:
I still have the (20) old jpg files, and 39 resized files (2 pieces of each, except the last one, which has a single resized version)
The filenames of the resized files start with the name of the last original file and end with a counter.
➜ 1998 ls
i--santa_ferenc-olaj-129_angyali_udvozlet.jpg
i--santa_ferenc-olaj-130_szentek_kozossege.jpg
i--santa_ferenc-olaj-130+_szentek_kozossege.jpg
i--santa_ferenc-olaj-131_te_vagy_a_kiraly_jezus.jpg
i--santa_ferenc-olaj-132_orom.jpg
i--santa_ferenc-olaj-133_cim_nelkul.jpg
i--santa_ferenc-olaj-134_atfestve_a_sziv_megterese.jpg
i--santa_ferenc-olaj-135_ave.jpg
i--santa_ferenc-olaj-136_isten_kezeben.jpg
i--santa_ferenc-olaj-137_peter_emlekere.jpg
i--santa_ferenc-olaj-138a_aldozat.jpg
i--santa_ferenc-olaj-138b_aldozat.jpg
i--santa_ferenc-olaj-139_jelenesek.jpg
i--santa_ferenc-olaj-140_atfestve_latomas.jpg
i--santa_ferenc-olaj-141_a_zaszlos.jpg
i--santa_ferenc-olaj-142_gondviseles.jpg
i--santa_ferenc-olaj-143_az_ido_tukreben.jpg
i--santa_ferenc-olaj-144_jelenesek_ii.jpg
i--santa_ferenc-olaj-145_jelenesek_iii.jpg
The last original file's name i--santa_ferenc-olaj-147_lanc.jpg is missing from here, eventhough I can see the image in the folder view. Then the resized images come:
i--santa_ferenc-olaj-147_lanc-0.jpg
i--santa_ferenc-olaj-147_lanc-10.jpg
i--santa_ferenc-olaj-147_lanc-11.jpg
i--santa_ferenc-olaj-147_lanc-12.jpg
i--santa_ferenc-olaj-147_lanc-13.jpg
i--santa_ferenc-olaj-147_lanc-14.jpg
i--santa_ferenc-olaj-147_lanc-15.jpg
i--santa_ferenc-olaj-147_lanc-16.jpg
i--santa_ferenc-olaj-147_lanc-17.jpg
i--santa_ferenc-olaj-147_lanc-18.jpg
i--santa_ferenc-olaj-147_lanc-19.jpg
i--santa_ferenc-olaj-147_lanc-1.jpg
i--santa_ferenc-olaj-147_lanc-20.jpg
i--santa_ferenc-olaj-147_lanc-21.jpg
i--santa_ferenc-olaj-147_lanc-22.jpg
i--santa_ferenc-olaj-147_lanc-23.jpg
i--santa_ferenc-olaj-147_lanc-24.jpg
i--santa_ferenc-olaj-147_lanc-25.jpg
i--santa_ferenc-olaj-147_lanc-26.jpg
i--santa_ferenc-olaj-147_lanc-27.jpg
i--santa_ferenc-olaj-147_lanc-28.jpg
i--santa_ferenc-olaj-147_lanc-29.jpg
i--santa_ferenc-olaj-147_lanc-2.jpg
i--santa_ferenc-olaj-147_lanc-30.jpg
i--santa_ferenc-olaj-147_lanc-31.jpg
i--santa_ferenc-olaj-147_lanc-32.jpg
i--santa_ferenc-olaj-147_lanc-33.jpg
i--santa_ferenc-olaj-147_lanc-34.jpg
i--santa_ferenc-olaj-147_lanc-35.jpg
i--santa_ferenc-olaj-147_lanc-36.jpg
i--santa_ferenc-olaj-147_lanc-37.jpg
i--santa_ferenc-olaj-147_lanc-38.jpg
i--santa_ferenc-olaj-147_lanc-3.jpg
i--santa_ferenc-olaj-147_lanc-4.jpg
i--santa_ferenc-olaj-147_lanc-5.jpg
i--santa_ferenc-olaj-147_lanc-6.jpg
i--santa_ferenc-olaj-147_lanc-7.jpg
i--santa_ferenc-olaj-147_lanc-8.jpg
i--santa_ferenc-olaj-147_lanc-9.jpg
i--santa_ferenc-olaj-147_lanc.jpg
What is the problem? :'(
Try this:
mogrify -resize 300 *.jpg

Compress m4a file created on the iphone before uploading them to the server

I have merged two streams of caff files into one streo file with the format of m4a/caff
the properties of the files are the following:
44100 Hz, 16bit stereo, 256kb/sec
for a 31 seconds file i get a 667 KB
what can i do to reduce the size of this file after the fact..?
can i convert it to a single channel (mono)? can i reduce the sample size or something like that?
I tried several sample application out their - but none of them gave me a good solution.
Do you have any idea?
Using this command line on the mac worked - but i don't know how to do it on iphone
sudo afconvert -d aac -f 'caff' -b 32768 call_record.m4a test_32.caf
Normally you'd use the ExtAudioFile API to do the conversion. To reduce the size you could convert to a compressed format like AAC. See some sample code here: https://developer.apple.com/library/ios/samplecode/iPhoneExtAudioFileConvertTest/Introduction/Intro.html