Is there a way to compress webp file with cwebp? - webp

I've compressed millions of jpeg files with using Google cwebp.
But some of them weirdly are bigger than the original jpeg files.
So I'm looking for a way to compress more these big webp files but couldn't find a way as cwebp is giving an error when I try to compress them again.
This is the command I'm using.
cwebp test1.webp -o test11.webp -quiet -q 50

Related

Extracting frames from a video created by muxing a bunch of images together is changing the integrity of the frames

I am trying to transfer a bunch of images as a video. What I am doing is simply muxing these static images into a video using the following commands.
ffmpeg -framerate 1 -i %02d.jpg -codec copy 1.mkv
After this, I verify the integrity of my static images and the frames in the video using -
ffmpeg -i %02d.jpg -f framehash -
and
ffmpeg -i 1.mkv -map 0:v -f framehash -
I get the same hashes so it means I have archived the images properly. Now next I send this video to my friend who extracts the frames using -
ffmpeg -i 1.mkv mkv%02d.jpg
Now after extracting the hashes don't remain the same that means the integrity is lost.
How to extract the frames as it is so that integrity is not lost?
Also if you any other way to achieve what I am trying, please advice.
Here are the hashes.
The command
ffmpeg -i 1.mkv mkv%02d.jpg
doesn't "extract" the JPEGs. It decodes the stored frames and re-encodes them using the MJPEG encoder.
Use
ffmpeg -i 1.mkv -c copy mkv%02d.jpg

Cleaning up an image for OCR with ImageMagick and 'textcleaner'

I have the following image that I'd like to prepare for an OCR with tesseract:
The objective is to clean up the image and remove all of the noise.
I'm using the textcleaner script that uses ImageMagick with the following parameters:
./textcleaner -g -e normalize -f 30 -o 12 -s 2 original.jpg output.jpg
The output is still not so clean:
I tried all kinds of variations for the parameters but with no luck.
Does anyone have an idea?
If you convert to JPEG, you will always have the type of artifacts you are seeing.
This is a typical "feature" of JPEG compression. JPEGs are never good for images showing sharp lines, contrasts with uniform colors between different areas of the image, using only very few colors. This is true for black + white texts. JPEG is only "good" for typical photos, with lots of different colors and shading...
Your problem will most likely completely get resolved if you use PNG as an output format. The following image demonstrates this. I generated it with the same parameters as your last example command used, but with PNG as the output format:
textcleaner -g -e normalize -f 30 -o 12 -s 2 \
http://i.stack.imgur.com/ficx7.jpg \
out.png
Here is a similar zoom into the output:
You can very likely improve the output even more if you play with the parameters of the textcleaner script. But that is your job... :-)

How to batch convert JPG image gallery to BPG image format

How to convert whole image gallery or family album from JPG to BPG image format?
I'm looking for some batch conversion tool, application or script on Windows platform.
Input directory must be processed recursively and image quality should be preserved.
Linux command line fragment I use for this task, with current directory being gallery of '*.JPG' files, without subdirectories.
parallel -i sh -c 'convert -quality 100 {} -scale "1280x1000>" {}.png && bpgenc -q 30 {}.png -o {}.bpg && rm -f {}.png' -- *.JPG
You may adjust (or remove) resizing and change -q 30 to lower value for more quality.
It depends on ImageMagick and bpgenc.
To run in on Windows, you probably will need Cygwin.
Look at
http://www.romeolight.com/products/bpgconv/
for nice Windows converter.
2 things to mention: Currently there is options menu in top right of window. And all BPG pictures are saved into folder on your desktop called bpg_encoded.
Martin

How to convert an image to PVRTC format

I've been using terminal to convert my jpg image named left to pvrtc format and this happens:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --bits-per-pixel-2 -o left.pvrtc left.jpg
Failed to load image
Failed to perform Encode
Change:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --bits-per-pixel-2 -o left.pvrtc left.jpg
To:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --bits-per-pixel-2 -o left.pvr left.PNG
The file must be a PNG
Updated instructions on OSX 10.10+
In Terminal, hit cd to make sure you're in your root directory.
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ && ls
This should show you a list of all the tools there (Make sure you see texturetool) - If you don't, update your OS, then Xcode
Once you know it's there, cd back to your root and run the tool like:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --bits-per-pixel-2 -f PVR -o [new path to pvr to go] [path of original png]
Your output pvr path can be ~/whatever/image.pvr and your input png is the path to your image to be converted.
HERE and HERE are other good walkthrough
The iPhone SDK includes a tool that allows you to create textures in the PVRTC compression format, aptly named texturetool. If you have Xcode installed with the iPhone OS 2.2 SDK in the default location (/Developer/Platforms/), then texturetool is located at: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool.
texturetool allows you to create four variants of PVRTC data, the primary difference being tradeoffs between quality and size. You will have to experiment with these variants to determine which setting is the best compromise for each individual texture image.
Apple Docs
HERE is some same code to help once you have your pvrtc file
HERE are some more docs
HERE is a good read on PVRTC stuff

Running a batch with imagemagick

I need to save a bunch (several thousand) of images with imagemagick.
I'm totally new to it, and its documentation seems totally opaque and totally labyrinth. Where's the quickstart guide?
Looking at it, I think I want to use mogrify.
so I cd to my program files directory where I installed imagemagick.
I run mogrify -format png *.png as I see in various examples.
It says:
mogrify: unable to open image `fgimg\': No such file or directory # blob.c/OpenB
lob/2489.
mogrify: unable to open file `fgimg\' # png.c/ReadPNGImage/2865.
How do I instruct it to run on all images in the subdirectory \fgimg?
Thanks a lot!
The problem here is that you're hitting the limit of how much you can put on a command line. You need to split it into chunks that will fit. This should work better:
find -name '*.png' -print0 | xargs -0 -r mogrify -format png
The -print0 and -0 are used to handle spaces in filenames, and the -r means don't run mogrify if there's nothing to do.

Resources