Animation is lost after converting png to webp - webp

I have an animated PNG image but after I convert it to webP - I get the static image without animation.
I've tried cwebp
$ cwebp -q 100 1.png -o 1.webp
$ cwebp -version
1.0.0
and the same with imagemagick
$ magick 1.png -quality 100 -define webp:lossless=true 1.webp
$ magick --version
Version: ImageMagick 7.0.10-29 Q16 x64 2020-09-05 http://www.imagemagick.org
How can I convert to save the animation?

As discovered, cwebp does not support conversion with animation. Possible solution is to extract the individual frames (using ffmpeg or imagemagick for instance) and use img2webp to generate the animation.

Related

imagemagic: how to split an image vertically based on aspect ratio and also with a vertical overlap

I have lot of images and not i want to split them w.r.t aspect ratio.
What is presently working is
convert -crop 2:1 input.png cropped_%d.png
The above command split the image. Assuming i have 900px x 2000px then it creates 5 images.
But now the problem is i want to keep some overlap
I tried
convert -crop 2:1+0+40 input.png cropped_%d.png
Its only giving one image.
I tried
convert -crop 1x4+0+40# Settings_commit1.png cropped_%d.png
This works well. But here i have to mention 1x4 (grid). But I want to do it by aspect ratio
I did the following way
$ convert --version
Version: ImageMagick 7.0.8-35 Q16 x86_64 2019-03-25 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib
The two commands split the image:
Based on aspect ratio split the image file (but overlap does not work 2:1+0+40)
convert -crop 2:1 input.png cropped_%d.png
Based on grid split the image file and overlap works (+0+40)
convert -crop 1x4+0+40# Settings_commit1.png cropped_%d.png (with 40px vertical overlap)
Logic is we get the number of split images from aspect ratio and then use it in grid
This is the scrip which worked
filename="someimage.png";
# just creating a dir and empty it
mkdir ~/croped
rm -rf ~/croped/*
# split the image base on aspect ratio and save them in croped folder
convert -crop 903:600 ${filename} ~/croped/crop_aspect_%d.png;
# count the number of files in the croped folder
number_files=`ls -l ~/croped | grep -E "crop_aspect_*" | wc -l`
# based on this number apply the grid
convert -crop 1x${number_files}+0+8# ${filename} ~/croped/crop_grid_%d.png

ffmpeg resize large image and high resolution

I tried to resize a very big image (457 MB and 21600x21600) with the following command
-i test.png -vf scale=320:-1 out.png
but it throws exception saying "Picture size 21600x21600 is invalid". How can I find out the biggest supported resolution by ffmpeg? Is there a way to resize this high resolution image with ffmpeg?
If you want to use ImageMagick it is included in most Linux distros and is available for macOS and Windows.
Your command becomes:
convert test.png -resize 320x result.png
If you are running v7 or newer, use:
magick test.png -resize 320x result.png
If you have lots to do, and you want all the resized images written in a directory called thumbs you can use:
mkdir thumbs
magick mogrify -path thumbs -resize 320x *.png
Alternatively, you may find vips is a lighter-weight installation and does a faster conversion using less memory:
mkdir thumbs
vipsthumbnail -s 320 -o "thumbs/%s.png" image.png

How to convert colored image from RAW to JPEG format

I'm trying to convert color image from .raw format into .jpg or .png format, I used ImageMagick with the following command prompt code:
convert -size 768X576 -depth 8 rgb:my_image.raw my_image.jpeg
It is work successfully to convert the image into jpeg format, but with some problems which are:
1- The resulted image is gray and not colored.
2- The resulted image is subdivided into 9 images as a grid of small images repeated.
When I change rgb into gray, return me 3 separated gray image with different in lighting conditions from darker to lighter.
I'm necessary need to convert the image format, can anyone please help me how can I edit the code or also any other software that able to open the image, I tried very software but they are usefulness, I use windows 10.
I tested it with my own raw input image, and it's working fine.
You may be using a wrong version of ImageMagick.
I downloaded the version: ImageMagick-7.0.8-49-Q8-x64-static.exe from https://imagemagick.org/script/download.php.
In the version I downloaded, the convert command is magick.exe and not convert.
The following command is working:
magick.exe -size 768x576 -depth 8 rgb:my_image.raw my_image.jpeg.
I prefer using FFmpeg for format conversion.
You can download it from https://ffmpeg.zeranoe.com/builds/
Select:
Version: stable (current version is 4.1.3).
Architecture: Windows 64-bit
Linking: static.
Extract the zip file, you only need ffmpeg.exe.
For converting the raw file to jpeg using FFmpeg you can use the following command:
ffmpeg -y -video_size 768x576 -pix_fmt rgb24 -i my_image.raw -pix_fmt yuvj444p my_image.jpeg
Assuming your raw file format is "chunky" RGB (ordered: r,g,b,r,g,b,r,g,b...), make sure the file size is 768*576*3 = 1,327,104 Bytes.
Just to make sure, the problem is not in your input file...
You can create an synthetic input raw image using FFmpeg and convert the result to jpeg:
Create synthetic input:
ffmpeg -y -f lavfi -i testsrc=duration=1:size=768x576:rate=1 -pix_fmt rgb24 -f image2 test_image.raw
Convert synthetic input:
ffmpeg -y -video_size 768x576 -pix_fmt rgb24 -i test_image.raw -pix_fmt yuvj444p test_image.jpeg
Result (test_image.jpeg):
I found the solution:
Apparently the raw image format is "planar" RGB:
RRRRR
RRRRR
RRRRR
GGGGG
GGGGG
GGGGG
BBBBB
BBBBB
BBBBB
Converting it to jpeg (using FFmpeg) is a complicated problem:
ffmpeg -y -video_size 768x576 -pix_fmt gbrp -i m-001-1.raw -filter_complex "extractplanes=g+b+r[g][b][r],[r][g][b]mergeplanes=0x001020:gbrp[v]" -map "[v]" m-001-1.jpeg
FFmpeg has no support for raw "planar" RGB format.
The only "planar" that is close to RGB is GBR (green plane is first).
I used extractplanes and mergeplanes for reordering the color channels.
ImageMagick has a much more simple solution:
magick.exe -depth 8 -interlace plane -size 768x576 rgb:image.raw image.jpeg
Example:
Since stackoverflow not allowing upload of raw files, I uploaded a png image in grayscale format that simulates the "planar" RGB:
For testing the solution use the following steps:
Download the image (imgur named it: D5IUp.png).
Convert from png to raw as "planar" RGB" (.y extension):
ffmpeg -y -i D5IUp.png -c:v rawvideo -pix_fmt gray D5IUp.y
Convert from raw to jpeg:
ffmpeg -y -video_size 128x96 -pix_fmt gbrp -i D5IUp.y -filter_complex "extractplanes=g+b+r[g][b][r],[r][g][b]mergeplanes=0x001020:gbrp[v]" -map "[v]" D5IUp.jpeg
Result:
Example for batch conversion using ImageMagick:
for %%f in (*.raw) do (magick.exe -depth 8 -interlace plane -size 768x576 rgb:"%%f" "%%~nf.jpeg")

ImageMagick no encode delegate

I used to be able to convert text to an image using ImageMagick but now I get this error message:
$ echo text | convert -background none text:- file
convert: no encode delegate for this image format `TEXT' # error/constitute.c/WriteImage/1167.
ImageMagick was installed using Homebrew
imagemagick: stable 7.0.7-10 (bottled), HEAD
Tools and libraries to manipulate images in many formats
https://www.imagemagick.org/
/usr/local/Cellar/imagemagick/7.0.7-10 (1,523 files, 23.1MB) *
Poured from bottle on 2017-11-10 at 15:46:33
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/imagemagick.rb
In IM 7, convert is replaced by magick. You also have not specified an output image format for "file". Try this:
echo "text" | magick -background none text:- file.png
or
echo "text" | magick -background none text:- PNG32:file
That works for me on IM 7.0.7.10 Q16 Mac OSX
What do you get from
magick -version
Does it include freetype?
If not, then you probably need to install Freetype with ImageMagick via Homebrew

.CDR to .SVG Convert Using ImageMagick

I am on CentOS 6.4 and trying to convert .CDR to .SVG Convert Using ImageMagick using SSH command.
my 1.cdr file is in /var/www/vhosts/website.com/httpdocs/test/1.cdr
once converted to SVG it should be created in the same folder
Tried the following command:
convert /var/www/vhosts/website.com/httpdocs/test/1.cdr image.svg
The Error I am getting is:
sh: mplayer: command not found convert: Delegate failed "mplayer"
"%i" -really-quiet -ao null -vo png:z=3' #
delegate.c/InvokeDelegate/1032. convert: missing an image filename
image.svg' # convert.c/ConvertImageCommand/2800.
Not sure what does that mean ?
In order to convert CDR files you need to install uniconvertor for CDR delegate.
List of all delegates:
convert -list delegate
By default it outputs:
cdr => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
Install uniconvertor. For example, on Ubuntu it’s:
sudo apt-get install python-uniconvertor
Then run:
convert image.cdr -flatten -thumbnail '512x512' image.png
Or, with zoom cropping:
convert image.cdr -flatten -thumbnail '512x512^' -gravity center -crop 512x512+0+0 +repage image.png
And you’re done.
I convert to PNG here but you may use your own output format.
python-uniconvertor is part of inkscape.
It does not exist by itself.
Ubuntu/Mint recently removed all the old Python stuff, for Corel Draw I have to fire up the WinXP VM & Corel and export something Linux understands, usually PNG, a favourite
CDR & WMF files are pretty much dead to Linux, ImageMagick can still handle WMF though.

Resources