Saving arbitrary bitmap region

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
tjames
Posts: 9
Joined: Sat Aug 22, 2009 7:56 pm

Saving arbitrary bitmap region

Post by tjames » Thu Nov 12, 2009 10:09 pm

I would like to save an image created by a script/applet but I don't know how to do it(efficiently). There is no img tag, just a container to hold the image. The SAVEAS TYPE=BMP works but that is overkill i.e. saving almost 7MB for the entire page vs only 0.5MB for the desired image. The direct screen command DS CMD=SCREENSHOT X=xxx Y=yyy is a little better as it only saves the visible portion of the page which can be partially trimmed with the SIZE X=xxx Y=yyy to just include the desired image.

A better solution (for me) would be to be able to fully specify bitmap region to capture, i.e. (x1,y1),(x2,y2). I'm not sure what the X=...Y= specs in the DS CMD=SCREENSHOT are supposed to do, but adding a WIDTH=...HEIGHT=... would do the trick if the X,Y are meant to indicate the center of the image, (as might result from the IMAGESEARCH command).

Thoughts???
tunaSalad
Posts: 26
Joined: Mon Jul 07, 2008 4:24 pm

Re: Saving arbitrary bitmap region

Post by tunaSalad » Fri Nov 13, 2009 3:50 pm

I'd like to see something like that as well.

Regarding the capture size, yes BMPs are large files. There should be left to the user which one to use: SAVEAS TYPE=JPG or SAVEAS TYPE=PNG, regardless of the browser being used (FF -> PNG only, Full page, IE -> BMP, not full page, iMacros -> BMP only, full page) I'm really looking forward to see iMacros, IE, FF -> BMP|PNG|JPG, full page!!

What I do in my macros to take screenshots is something like this

Code: Select all

SAVEAS TYPE=BMP FOLDER={{sshotfolder}} FILE={{sshotprefix}}_001.bmp
ADD !EXTRACT {{sshotprefix}}_001.bmp
ADD !EXTRACT {{!URLCURRENT}}
Once the macro finishes the !EXTRACT variable stores pairs of values such:

Code: Select all

Screenshotname1[EXTRACT]URLofSceenshot1[EXTRACT]Screenshotname2[EXTRACT]URLofSceenshot2[EXTRACT]
I feed that string to a custom function that will do the following for me:

1. Break the string into pieces
2. Load the BMP
3. Using GDI+ stamp the URL where that BMP was taken
4. Save the resulting BMP as JPG and remove the original BMP.

This saves loads of disk space in our server and also give us the added feature of having the URL embedded in the screenshot, a feature that iMacros does not implement.

Obviosly you will need the scripting version of iMacros to do this...
Last edited by tunaSalad on Mon Nov 16, 2009 6:19 pm, edited 1 time in total.
Hannes, Tech Support

Re: Saving arbitrary bitmap region

Post by Hannes, Tech Support » Mon Nov 16, 2009 10:39 am

I have forwarded your suggestion to the dev team (internal ticket# io132).
Post Reply