Archive

Archive for March, 2013

Convert all images in a folder on linux with imagick

March 22, 2013 Leave a comment

Not complicated, but it took me a little while to figure it out. So here it comes :

for f in *; do convert “$f” -quality 50 “$f”; done

if you want to change the name of the output files :

for f in *; do convert “$f” -quality 50 “XXXXXX$f”; done

Categories: Uncategorized

ImageSnapshot and BitmapData size limit

March 6, 2013 2 comments

With Flex you can use ImageSnapshot class to copy FlexComponent to an image (PNG or JPEG).

It’s very easy, all you have to do if to execute those two lines :

var encoder:PNGEncoder= new PNGEncoder();
var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(mycomponent, 300, encoder);

mycomponent is you Flex component (UIComponent), 300 is the resolution (DPI) and I used a PNGEncoder to get a PNG file. I could have used a JPEGEncoder to get a Jpeg File.

This class uses BitmapData class to create a bitmap file and encode it. Until Flash Player 9, BitmapData was limited in size to 2880 pixels.
So if your component was bigger than that, it would be scalled to fit that size 2880 x 2880.

From Flash Player 10, BitmapData can go till 8191 pixels width or height. But it seems ImageSnapshot class was not updated. It still uses the old limit. So if you need more resolution on your screenshots, you will have to override the ImageSnapshot class.

I overrided it and set the const MAX_BITMAP_DIMENSION to 4600 and it’s working fine, and my screenshots are twice better.

UPDATE : 4600 was fine for a while, then depending on the area I try to create a snapshot from, it wasn’t always working.
I reduced it to 3950, and it’s working now.

Categories: Uncategorized