I have a small problem, I have a set of animated gif images. I want to pick individual gif image files, and create multiple tiff images capturing individual frames.
I am looking to do it in Python/Java.
Help would be appreciated!
You can do this easily from the command-line using ImageMagick. It is available for free from here. It has bindings for Perl, C/C++, Python and lots of others. It is ready installed in many Linux distros.
Your command looks like this:
convert -coalesce input.gif %02d.tif
which will produce TIFF format output files, numbered 01.tif, 02.tif etc. according to the frame number.
You can also extract an individual frame, say frame 7, like this:
convert -coalesce input.gif[7] my_favourite.tif
or a sequence of frames, say 3-7 like this:
convert -coalesce input.gif[3-7] frames%02d.tif
Note however, that when you extract individual frames, you may get artefacts depending on how well compressed your original GIF files are - since they sometimes only store DIFFERENCES between frames, so you may be best advised to extract all frames then discard any you don't want.
Related
That is, if I have image.png and it happens to be an interlaced image, I would like to split the file at the exact offsets where an interlacing block is present. I would like to have the same thing for progressive .jpg files.
I can read the specs and try to figure it out from there, but it would be nice if such a thing existed in e.g. ImageMagic or any other library/tool.
I am looking for a way to "find" animated GIFs so I can remove them from a folder.
This must work on Windows 7 or Windows XP.
Edit: I am looking to distinguish between animated and regular GIFs. If I could select all GIFs that might be ok as then I could sort by size, but some GIFs are saved with the extension .jpg! That is why I think I probably need a special Image viewer program.
You can use ImageMagick to get the number of frames in a GIF like this:
identify -format "%[scene]\n" YourImage.gif[-1]
identify -format "%[scene]\n" YourImage.jpeg[-1]
It actually gets the frame number of the last frame, so if the image has 37 frames, it will tell you that frame 36 (starting at zero) is the last. So, an animated GIF will give an output of 1 or more since it has multiple frames.
This also works, if the image is mis-named by using a different name suffix. ImageMagick isn't fooled by this, it will still discover that in reality it is a GIF. If it is a standard JPEG, or a GIF with only 1 frame it will return 0.
ImageMagick is free and available for OSX, Linux and Windows - here.
I have used MiniMagick to compress JPEG files.
With strip function, I want to get rid of EXIF from image. So, I do:
image = MiniMagick::Image.open("my_picture.jpg")
image.strip
image.write("my_picture_small.jpg")
but sometimes the size of my_picture_small.jpg is bigger than my_picture.jpg.
However, when I don't use the strip function, like
image = MiniMagick::Image.open("my_picture.jpg")
# image.strip
image.write("my_picture_small.jpg")
my_picture_small.jpg's size is smaller.
That situation happened with some picture deal with Photoshop and in my CentOS computer, but run well with my Macbook. I don't know why stripping some information led to more storage.
Can anyone explain it?
Have found that ImageMagick will recompress image even if it with any arguments, such as
convert image.jpg new_image.jpg
new_image.jpg will be different from image.jpg more or less. If image.jpg is from a phone or camera or a image processing tools, the degree of difference is also different.
So compress images with MiniMagick or Rmagick that use ImageMagick as there system support, just do convert -strip image.jpg new_image.jpg may led to a unexpected result, avoid to use MiniMagick command if there is no need to greatly compress file.
I have several postscript images of the form "filename_0001.ps", "filename_0002.ps", etc. I would like to create an animated gif with each of the files as a frame in the animation, but I do not know how I would go about doing that. I have over 500 files that I would like to include in a single gif and would like to avoid creating the animated gif by hand.
I googled around for a bit and found this. At the very bottom it seems to suggest that there is a one line command that can be used to make the gif, but I haven't been able to figure out how to use it in my case.
Any suggestions would be appreciated.
I've used ghostscript and ImageMagick's convert to do this. I used these commands
gs -sDEVICE=png48 -g500x500 -o bezan%03d.png bezanim.ps
convert bezan*.png bezan.gif
to produce this animation for this Codegolf.Stackexchange challenge, where the frames were separate pages of a single postscript program.
You can probably do it with the single command
convert filename_*.ps anim.gif
and convert will shell-out to ghostscript as needed. But for my case, I wanted to specify the arguments to ghostscript directly.
I have some raw data in a file that I would like to store in an image file (bmp, jpg, png, or even gif (eegad)). I would like this to be a two way process: I need to be able to reliably convert the image file back later and get a file that is identical to the original file.
I am not looking for a how-to on steganography; the image file will probably be one pixel wide and millions of pixels high and look like garbage. That is fine.
I looked into the Imagemagick utility convert, but am intimidated by the large number of options and terse man page. I am guessing I could just use this to convert from a 'raw' black channel to png, but would have to specify a bunch of other stuff. Any hints? I would prefer to work within Imagemagick or using Linux utilities.
If you are wondering, there's nothing black hat or cloak and dagger about my request. I simply want to automatically backup some important data to a photo-sharing site.
I'd plow into ImageMagick if that's what you'd prefer anyway.
Specific image formats support storing text data to different degrees, and ImageMagick supports all of the formats you mentioned. I'd choose the one that lets you store what you need.