WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Selecting an area of the screen for a screenshot using your mouse  (Read 34801 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11656
I wrote a front end for the imlib2_grab utility that lets you use your mouse to select the section of your screen you want
to save. Here is a shot that shows part of my screen outlined:

And this is the output:

The program is relatively compact at 4541 bytes. Packaged with an icon it fits in an 8K tcz.
It's only dependencies are:
Code: [Select]
tc@box:~/guilib/grabber$ ldd grabber
        linux-gate.so.1 =>  (0xb770e000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0xb75ff000)
        libc.so.6 => /lib/libc.so.6 (0xb74f4000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0xb74f1000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb74eb000)
        libdl.so.2 => /lib/libdl.so.2 (0xb74e7000)
        /lib/ld-linux.so.2 (0xb770f000)
which imlib2_grab requires anyway.
Operation is straightforward. Start it from the command line or click the icon. Outline a section of the screen by holding
the left mouse button and dragging. Hit 's' to save. Repeat as required. Hit 'q' to quit. Files are saved with the following
naming format:
Code: [Select]
/home/tc/screengrab-2015May14-03:12:28.png
« Last Edit: May 14, 2015, 11:44:21 AM by Rich »

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #1 on: May 14, 2015, 10:02:34 AM »
Awesome Thx 


Sent from my iPhone using Tapatalk

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11656
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #2 on: June 04, 2015, 02:25:35 AM »
I decided to do a little more work on the program. I removed the imlib2_grab dependency in favor of linking to libImlib2
directly. Also added a coordinates window that displays the origin, width, and height of the selected area:

Sorry the above picture is a little blurry, the picture hosting site rescaled it.. This shows the selected area:

I've also added a keyboard interface to allow fine tuning of the selected areas size and location and added a configuration
file. Details in the attached files below. The extension has been submitted for TC3 and TC4, though I do believe it will
also run under TC5 and TC6 which I indicated when I submitted it. The only difference being TC5 and TC6 have an  imlib2.tcz
dependency since it was removed from base, though its version number is unchanged.


Offline Stone.Giant

  • Full Member
  • ***
  • Posts: 100
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #3 on: June 05, 2015, 12:17:53 AM »
will i still use some image viewer like xzgv, gimp v2, etc. ?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11656
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #4 on: June 05, 2015, 12:44:48 AM »
Hi Stone.Giant
Quote
will i still use some image viewer like xzgv, gimp v2, etc. ?
If you wish to view the file(s) you saved, yes. The program only saves the section of the screen you selected as a .png file.
It does not open files for viewing.

Offline Stone.Giant

  • Full Member
  • ***
  • Posts: 100
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #5 on: June 05, 2015, 01:24:42 PM »
I already have imlib2_grab but not working. What else do I need?
Code: [Select]
seed@avocado:/$ imlib2_grab
Usage: imlib2_grab [-v] [-id <drawable id>] [-width <width>] [-height <height>] [-noshape] <output file>
seed@avocado:/$ sudo find -name /guilib
seed@avocado:/$ sudo find -name /grabber

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11656
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #6 on: June 05, 2015, 03:32:49 PM »
Hi Stone.Giant
You have to wait until the grabber extension I sent in gets added to the repository. Then you can install it.

Offline Stone.Giant

  • Full Member
  • ***
  • Posts: 100
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #7 on: June 07, 2015, 01:40:29 AM »
Hi Stone.Giant
You have to wait until the grabber extension I sent in gets added to the repository. Then you can install it.

Why u didn't say so :-)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11656
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #8 on: June 07, 2015, 05:18:16 PM »
The grabber extension has been added to the TC3 and TC4 repositories.

If someone running TC5 or TC6 would be willing to test to verify it runs under those versions it would be appreciated. For TC5
and TC6 you will also need  imlib2.tcz

Offline beroje

  • Full Member
  • ***
  • Posts: 130
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #9 on: June 14, 2015, 12:15:23 AM »

Utilidad excelente. Funciona para mi en Core5

Excellent utility. It works for me in Core5

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11656
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #10 on: June 14, 2015, 01:07:22 AM »
Hi beroje
Glad you like it. Thank you for confirming it runs under TC5.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11656
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #11 on: June 30, 2015, 04:21:14 PM »
Continued from here:
http://forum.tinycorelinux.net/index.php/topic,15906.msg113496.html#msg113496

Hi nitram
Under TC4 running flwm_topside the program runs perfectly, so I installed fluxbox and saw the behavior you described where the
screen appears to shift up and the user panel at the top of the screen shows up twice. I also noticed each time the  n  key was
pressed to invoke another instance of grabber, the screen would shift down.  It seems the window manager is a bit grabby with
my window and ignored my polite request for size, position, and placement on the display stack. So I made some changes and
ask the window manager in a firmer tone of voice to keep it's mitts off my window. The above problems both seem to be resolved.
I will PM you a link to download the new version of grabber.tcz to try out.
« Last Edit: June 30, 2015, 04:24:33 PM by Rich »

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #12 on: June 30, 2015, 06:08:41 PM »
Hi Rich. Just tested, works well in TC6 using Fluxbox. The screen stepping behaviour totally eliminated. I performed several next invocations and still no wierd screen shift.

Something else. When i tested your original grabber.tcz a .png file was saved to home directory and double-clicking the file in Fluff properly opened the image in Firefox. With this version, the image gets sent to a new Firefox tab but the image does not load with the following error:
Quote
Firefox doesn't know how to open this address, because one of the following protocols (grabber-2015jun30-15) isn't associated with any program or is not allowed in this context.
The default .png save is something like:
grabber-2015Jun30-15:47:54.png
When i eliminate colons and underscores then Firefox opens the image without complaint:
grabber2015Jun30154754.png
I did, however, forget to delete my old grabber.conf file. I will purge the old config file and retest upon rebooting later today. Did something get changed with the naming nomenclature? Note: Opening the .png image through Firefox (Firefox > file > openfile), just not via double-click Fluff. Strange. Will update again later.

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #13 on: June 30, 2015, 07:07:22 PM »
Sorry i was hurried earlier. Removed old grabber.conf and rebooted, reloaded new grabber, new config, works well. Same Firefox issue as above. Really a Firefox issue but would be nice to open the .png file across any application without hassle. Try to keep my installs simple so Firefox is used as a rarely needed image viewer.

The .png images open perfectly in Firefox via Fluff double-click when the colons are replaced in the default filename:
grabber-2015Jun30-16:35:30.png     ---> not work
grabber-2015Jun30-16C35C30.png     ---> works

In addition to saveprefix=grabber in grabber.conf, would you consider changing the default or providing an option to save the time format as something like grabber-2015Jun30-163530.png?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11656
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #14 on: June 30, 2015, 09:31:32 PM »
Hi nitram
Quote
Quote
Firefox doesn't know how to open this address, because one of the following protocols (grabber-2015jun30-15) isn't associated with any program or is not allowed in this context.
The default .png save is something like:
grabber-2015Jun30-15:47:54.png
When i eliminate colons and underscores then Firefox opens the image without complaint:
grabber2015Jun30154754.png
I did, however, forget to delete my old grabber.conf file. I will purge the old config file and retest upon rebooting later today. Did something get changed with the naming nomenclature?
No, the format did not change.


Come to think of it, when using tab completion on one of those file names, the colons wind up being escaped with a backslash.
OK, colons will be removed as will be the leading dash. The default filename will look like:
Code: [Select]
YYYYmonthDD-HHMMSS.pngFour digit year, three character month, two digit day, dash, six digit time stamp in 24 hour format.

If you still have IceWm loaded, I'd appreciate if you could test grabber with that.
I'll PM you a link with the revised version.