jpegoptim doesnt compress file - image

I have jpegoptim version 1.2.3, and PageSpeed Insights says that I can reduce my image by 36,6 KB (95 %). But using jpegoptim image.jpg --strip-all
image.jpg 147x196 24bit JFIF [OK] 39227 --> 39227 bytes (0.00%), skipped. does nothing.

jpegoptim could not compress lossless your image, you could add --max=60 to force lossy compression.
A lot of online JPEG optimizers (compressjpeg.com, tinyjpg.com) use lossy compressions.

I ran the image through Compress JPG and reduced it to 12K.

Related

How to compress gif effectively to reduce size?

We use gifs for our blog extensively. We used to embed tenor nano gifs(90px height maintaining aspect ratio, used for GIF previews and shares on mobile) in it. Now we wanted to create our own gifs and are using the following command to convert mp4 to gif while maintaining the properties of tenor's nano gif. using ffmpeg version 4.1.4
But we observed a huge difference in size between the gif we created and the one created using tenor.
ffmpeg -i input.mp4 -filter_complex "[0:v]fps=10,scale=-1:90:flags=lanczos,split [a][b];[a] palettegen [p];[b][p] paletteuse" -y output.gif
[Original MP4] - 845KB
Tenor Nano gif - 42KB
ffmpeg gif - 106KB
We even tried changing dithering algorithm to further reduce size but it ended up adding noise and damaged the gif quality
paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle
We tried tweaking colour quantization in gifsicle as well but it was of no use.
gifsicle --resize _x90 --colors 256 --color-method diversity --dither=ordered --resize-method sample input.gif > output.gif
What worked for me was specifying a lower frame rate (-r 10) for the output gif. Probably not what you want if you're after quality but if you're after quality file size may be the compromise.
Try this bat file. I wrote it for myself. I have Windows os.
It converts FFmpeg mp4 to gif
Create two packages Your_files and Result put the bat file next to the folders.
Put these folders and baht file next to ffmpeg.exe
Drag your files (file) to the Your_files folder
Run bat file
We take the finished files from the Result folder
color a
#echo off
set a="Your_files\*.mp4"
set b="Result\%%~na.gif"
set c=ffmpeg
set f=-filter_complex "[0:v] fps=10,scale=-1:-1:flags=full_chroma_int,split [a][b];[a] palettegen=max_colors=255:reserve_transparent=1:stats_mode=diff [p];[b][p] paletteuse=dither=none:bayer_scale=5:diff_mode=rectangle:new=1:alpha_threshold=128" -gifflags -offsetting
for %%a in (%a%) do (%c% -y -i "%%a" %f% %b%)
If it crashes, remove these lines: -gifflags -offsetting

ImageMagick "Channel distortion: Undefined" message

I installed imagemagick for Windows from official site. I am trying to generate a diff image from two PNG images using ImageMagick. I am using following command:
compare file2.png file1.png -compose Src "diff.png"
But command exits with EXIT code "1". When run with -verbose flag, below message gets printed.
Image:file2.png Channel distortion: Undefined
I searched google for possible reason, but haven't found any answer. There is official ImageMagick documentation on distortion, but that is too wide and technical (and I am a novice).
Any idea why this message is thrown by imagemagick utility?
There is no real error. That message comes up when you do not specify -metric XXX with compare and take the default. The exit code 1 is what ImageMagick produces on success, I believe. See if you have an output file called diff.png. If you add -metric rmse, for example, you should not get that message. If I run the following without -metric XXX, I get:
compare -verbose lena.png lena.jpg -compose src diff.png
lena.png PNG 256x256 256x256+0+0 8-bit sRGB 118327B 0.010u 0:00.004
lena.jpg JPEG 256x256 256x256+0+0 8-bit sRGB 31640B 0.000u 0:00.002
Image: lena.png
Channel distortion: Undefined
lena.png=>diff.png PNG 256x256 256x256+0+0 8-bit sRGB 3c 1322B 0.130u 0:00.039
So it works fine. The message is telling you that it does not know which metric to use to give you difference statistics. I am not sure what it uses to generate the output. The term distortion may be a poor choice and perhaps should have been difference statistics.
If I add -metric rmse, then I get:
compare -verbose -metric rmse lena.png lena.jpg -compose src diff.png
lena.png PNG 256x256 256x256+0+0 8-bit sRGB 118327B 0.010u 0:00.004
lena.jpg JPEG 256x256 256x256+0+0 8-bit sRGB 31640B 0.000u 0:00.001
Image: lena.png
Channel distortion: RMSE
red: 810.821 (0.0123723)
green: 658.701 (0.0100511)
blue: 945.653 (0.0144297)
all: 813.547 (0.0124139)
Similar or same resulting image, but now the compare scores are reported since a specific metric is specified.
See the section about comparison statistics here

ImageMagick convert cache directory

I was trying to use the convert command (OS X El Capitan) to convert a .mod video to .mp4 and it quickly filled up my disk space and I had to Control + C to halt it.
But after restart, the disk space is still filled and I don't know where the cache, i.e. the half converted video is and I don't know how to delete it. Can anyone help?
Thank you!
If you have set either of the two environment variables:
MAGICK_TEMPORARY_PATH
MAGICK_TMPDIR
then ImageMagick will use that directory for its temporary files. So, the first way to check is to run
env | grep -i MAGICK
and see if you have either set.
Failing that, or if you have no environment variables set, the easiest way I know to find where ImageMagick caches on disk is to turn on cache debugging and force ImageMagick to go to disk. So, we can turn on cache debugging with:
convert -debug cache ...
and we can force ImageMagick to go to disk by limiting the RAM it is allowed to use with:
convert -limit memory 100k ...
So, if we put that together:
convert -debug cache -limit memory 100k -size 1000x1000 xc:gray image.jpg
2016-05-19T13:25:46+01:00 0:00.000 0.000u 6.9.4 Cache convert[46510]: cache.c/SetPixelCacheExtent/3500/Cache
extend gray[0] (/var/tmp/magick-46510CYSKWOdhlrym[3], disk, 8MB)
2016-05-19T13:25:46+01:00 0:00.010 0.000u 6.9.4 Cache convert[46510]: cache.c/OpenPixelCache/3776/Cache
open gray[0] (/var/tmp/magick-46510CYSKWOdhlrym[-1], Map, 1000x1000 7.629MiB)
And, if you look carefully, you can see it is using /var/tmp on my Mac OSX - your system may be different, but this technique should show you what it is using.
Just as a test, I can set an environment variable and check ImageMagick is using it:
# Tell IM where to cache stuff on disk
export MAGICK_TEMPORARY_PATH=/tmp/TEMPPATH
# Force an operation that will require caching
convert -debug cache -limit memory 100k -size 1000x1000 xc:gray image.jpg
2016-05-19T14:09:51+01:00 0:00.000 0.000u 6.9.4 Cache convert[46584]: cache.c/SetPixelCacheExtent/3500/Cache
extend gray[0] (/tmp/TEMPPATH/magick-46584CivsEmIPjwv2[3], disk, 8MB)
2016-05-19T14:09:51+01:00 0:00.010 0.000u 6.9.4 Cache convert[46584]: cache.c/OpenPixelCache/3776/Cache
open gray[0] (/tmp/TEMPPATH/magick-46584CivsEmIPjwv2[-1], Map, 1000x1000 7.629MiB)
Keywords: ImageMagick, environment variables, tmp, TEMPDIR, TEMPPATH, cache, disk, cache

Determine bit depth of bmp file on os x

How can I determine the bit depth of a bmp file on Mac OS X? In particular, I want to check if a bmp file is a true 24 bit file, or if it is being saved as a greyscale (i.e. 8 bit) image. I have a black-and-white image which I think I have forced to be 24 bit (using convert -type TrueColor), but Imagemagick gives conflicting results:
> identify -verbose hiBW24.bmp
...
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: Gray
> identify -debug coder hiBW24.bmp
...
Bits per pixel: 24
A number of other command-line utilities are no help, it seems:
> file hi.bmp
hi.bmp: data
> exiv2 hiBW24.bmp
File name : hiBW24.bmp
File size : 286338 Bytes
MIME type : image/x-ms-bmp
Image size : 200 x 477
hiBW24.bmp: No Exif data found in the file
> mediainfo -f hi.bmp
...[nothing useful]
If you want a commend-line utility try sips (do not forget to read the manpage with man sips). Example:
*terminal input*
sips -g all /Users/hg/Pictures/2012/03/14/QRCodeA.bmp
*output is:*
/Users/hg/Pictures/2012/03/14/QRCodeA.bmp
pixelWidth: 150
pixelHeight: 143
typeIdentifier: com.microsoft.bmp
format: bmp
formatOptions: default
dpiWidth: 96.000
dpiHeight: 96.000
samplesPerPixel: 3
bitsPerSample: 8
hasAlpha: no
space: RGB
I think the result contains the values you are after.
Another way is to open the image with the previewer preview.app and the open the info panel.
One of the most informative programs (but not easy to use) is exiftool by Phil Harvey http://www.sno.phy.queensu.ca/~phil/exiftool/ , which also works very well on MacOSX for a lot of file formats but maybe an overkill for your purpose.
I did this to investigate:
# create a black-to-white gradient and save as a BMP, then `identify` it to a file `unlim`
convert -size 256x256 gradient:black-white a.bmp
identify -verbose a.bmp > unlim
# create another black-to-white gradient but force 256 colours, then `identify` to a second file `256`
convert -size 256x256 gradient:black-white -colors 256 a.bmp
identify -verbose a.bmp > 256
# Now look at difference
opendiff unlim 256
And the difference is that the -colors 256 image has a palette in the header and has a Class:PseudoClass whereas the other has Class:Direct

jpg won't optimize (jpegtran, jpegoptim)

I have an image and it's a jpg.
I tried running through jpegtran with the following command:
$ jpegtran -copy none -optimize image.jpg > out.jpg
The file outputs, but the image seems un-modified (no size change)
I tried jpegoptim:
$ jpegoptim image.jpg
image.jpg 4475x2984 24bit P JFIF [OK] 1679488 --> 1679488 bytes (0.00%), skipped.
I get the same results when I use --force with jpegoptim except it reports that it's optimized but there is no change in file size
Here is the image in question: http://i.imgur.com/NAuigj0.jpg
But I can't seem to get it to work with any other jpegs I have either (only tried a couple though).
Am I doing something wrong?
I downloaded your image from imgur, but the size is 189,056 bytes. Is it possible that imgur did something to your image?
Anyway, I managed to optimize it to 165,920 bytes using Leanify (I'm the author) and it's lossless.

Resources