How to render GIF animations in urxvt in order to integrate animated previews in ranger? - gif

Ranger optionally uses the w3mimgdisplay binary in order to display image previews in the terminal. Similarly I would like animated gifs to be animated in ranger's preview area. I've been testing in urxvt:
#! /bin/bash
clear
gifsicle -e $1
for f in *.gif.*
do
sleep .05s
echo -e "0;1;0;0;200;160;;;;;$f\n4;\n3;" | /usr/lib/w3m/w3mimgdisplay
rm $f
done
clear
But that's ugly I know. I'd much rather choose the window id for gifview like gifview -w 0x360000b -a some.gif but weird stuff happens with the urxvt background and I want to be able to have ranger control the width and position. The preview should be scalable and auto-repeating. If the original frame rate is sacrificed, so be it.

Related

Spit PNG into multiple images on Ubuntu with imagemagick

This image contains 30 blocks of user data. I plan to extract these 30 blocks as PNG files and then run tesseract-ocr to extract text from them. Can someone tell me how I can use imagemagick to get those 30 PNG files?
The following works for me in ImageMagick. I first crop to the array of boxes. Then I crop a set of 3x10 equal sized boxes.
convert image.png -crop 1125x1500+43+99 +repage -crop 3x10# +repage result_%02d.png
See
http://www.imagemagick.org/Usage/crop/#crop_repage
http://www.imagemagick.org/Usage/crop/#crop_equal
Imagemagick will work well. In their document , there are eamxamples that you can use
convert rose: -crop 40x30+10+10 crop.gif
# from point (40, 30) take a (width=10, height=10) frame and save into crop.gif
In your case, you have to find correct coordinate and size, then you can do it automatically. Just run and try, it will not consume too much time.
Hope that help

How can I animate a line drawing using SVG?

I'm trying to run this https://jsfiddle.net/kfbzhy9p/ as one continuous line but it breaks into two and doesn't seem to connect. If I stop the animation it's only partly drawn. I'm saving the path using illustrator and object >> compound path >> make Could this be the stroke-miterlimit attribute?
Your path is approximately 1908 units long, that's why treating it as something 1000 units long makes things look odd.

How can I display a JPG image so that a very low resolution displays first?

I've noticed that on some sites, a very low resolution version of an image gets displayed underneath the final version before it's done loading, to give the impression that the page is loading faster. How is this done?
This is called progressive JPEG. When you save a picture using a tool like Photoshop you need to specify you want to use this JPEG flavor.
I've found this Photoshop "Save for Web" dialog sample where you will find the whole Progressive option enabled:
What you are asking for depends upon the decoder and display software used. As noted, it occurs in progressive JPEG images. In that type of JPEG, the coefficients are broken down into separate scans.
The decode then needs to update the image in between decoding scans rather than just at the end of the image.
There was more need for this in the days of dial up modems. Unless the image is really large, it is usually faster just to wait and display the whole image.
If you are programming, the display software you use may have an option to update after scans.
Most libraries now use a model where you decode an image file stream into a generic image buffer. Then you display the image buffer. In this model, there generally is no place to display the images on the fly.
In short, you enable this by creating progressive JPEG images. Whether the image displays fading in dependents entire on what is used to display the image.
As an alternative, you can batch optimize all your images using the ImageMagick's convert command like this:
convert -strip -interlace plane input.jpg output.jpg
You can use these other options instead of plane.
Or just prefix the output's filename with PJPEG
convert -strip input.jpg PJPEG:output.jpg
Along with a proper file search or filename expansion (e.g.):
for i in images/*; do
# Your conversion command
done
The strip option is for stripping any profiles or comments, to make the conversion "cleaner". You may also want to set the -quality option to reduce the quality loss.

Create smooth animations on video from camera

I am working on a project where i need to place a image file on the detected object as here: https://github.com/mtschirs/js-objectdetect/blob/master/examples/example_sunglasses_jquery.htm .
I can complete my objective with this example.
But how do i make the image file to be stable to stick to the persons head
.
https://github.com/mtschirs/js-objectdetect
If you have a close look of the PICK YOUR GLASS video, it causes a jerk/zoom in-out effect on the glass image file when tracking your head at some cases. How can i prevent this or make this happen in a smooth way.

how to create gif animation from a stack of jpgs

I have around 200 jpg images. I need to stack them so that i can convert them into a simple animated gif image. Are there any free tools available to do that job? My os is windows.
I'm not so bothered about the quality of the output.
Try using ImageMagick's convert utility. I have used it to create animated gifs from a set of images (in any format) in the past.
Use the command
convert -delay 20 -loop 0 *.jpg animated.gif
Might want to look at GiftedMotion: http://www.onyxbits.de/giftedmotion
In theory this would work
ffmpeg -f image2 -i image%d.jpg video.avi
ffmpeg -i video.avi -pix_fmt rgb24 -loop_output 0 out.gif
If you'd like a flexible on-line solution, I just used GIFmaker.me and it worked great. It lets you change the frame order, change the size, set the speed, and set the repeat cycles. You can view the animated GIF and download it when you're finished.
Edit: I just used another on-line tool that GIFmaker refers to on their site. GIFcreator is even more flexible, letting you duplicate frames, change the delay for each frame, remove frames, and reverse frames. It also has a more flexible resize capability.
ImageJ and FIJI provide a powerful GUI for doing this is (FIJI is a re-package of ImageJ that also includes some widely used plugins). These powerful (but free!) programs may be overkill, but depending on your needs this may be the way to go, since this is a somewhat common and crucial task for biologists.
Also FIJI can open a large array of different image types, can save to GIF or AVI, and it is very easily scriptable (insternally with in Python or Java) for automating custom tasks etc.
Step-by-step instructions (from Here and Here) are as follows:
Put your images in a folder, and name them in sequence (eg. make sure they
open alphabetically in the right order, perhaps by adding the
desired frame numbers to the start of the filenames).
(On MacOS, this automator action could help)
In FIJI, Select `File > Import > Image Sequence..."
Choose your folder, and then any options (eg. scaling the images)
Preview the video with the Play button in the resulting window's
corner.
To change the frame rate, choose Image > Stacks > Animation > Animation Options...
Select File > Save As > Animated GIF... or AVI... and you're done.
For GIF you can choose the delay between frames (ie. frame rate), and looping option. For AVI you can choose the frame rate.