Page 1 of 1

pxruler - measuring pixels on screen

Posted: Sat Jul 18, 2020 7:03 am
by MochiMoppel

pxRuler can measure the height and/or width of any stuff on screen. Units are pixels - hence the name ;)

Just decompress the attached pxruler script, make it executable and run it.

It will show a dialog with 2 modes to measure distances:
Distance: Requires to click 2 points on screen. In many cases more convenient than a ruler.
Ruler: Shows a ruler as wide as the screen. Can be rotated 90 degrees with key R.
Key D will display the Distance dialog.
Key F1 provides further explanations.
The ruler needs to have focus in order to accept keyboard input, Clicking on the ruler before pushing any of the shortcut keys will ensure that keystrokes are recognized. .

For convenience I also attach a .pet archive. It will install the script to /usr/bin and add a menu item to the Graphics menu.

:!: Tip: To skip the initial dialog change the first line of the script from MODE=start to MODE=measure
The script will start with a crosshair cursor.

pxruler.png
pxruler.png (4.52 KiB) Viewed 2044 times

Changelog
2021-10-22 vers.2.0
- added option to measure distance manually by clicking 2 points on screen

2020-08-19 vers.1.1
- fixed issue with most recent svg libs
- fixed help text
- changed shell from busybox ash to bash sh

2020-07-18 vers.1.0
- first edition


Re: pxruler - measuring pixels on screen

Posted: Sat Jul 18, 2020 9:01 pm
by 01micko
Thank you MochiMoppel

A very handy tool for GUI building.

Re: pxruler - measuring pixels on screen

Posted: Mon Jul 20, 2020 2:33 am
by greengeek
Hi MochiMoppel, I just tried this on PuduanPup6.0.0 and got the following result:

Code: Select all

# ./pxruler
./pxruler: line 19: xwininfo: not found
(It's just one of many pups i am trialling while trying to recover data lost fom Murga forum)
Will test on other pups too. Will be very useful. cheers

Re: pxruler - measuring pixels on screen

Posted: Mon Jul 20, 2020 5:25 am
by MochiMoppel
@01micko You're welcome. Thanks for testing.
@greengeek If your PuduanPup lacks xwininfo, a basic tool, expect many more scripts to fail, not just mine. Try with a decent distro or edit pxruler and replace the routine that detects the screen size.

Re: pxruler - measuring pixels on screen

Posted: Mon Jul 20, 2020 5:55 am
by greengeek
MochiMoppel wrote: Mon Jul 20, 2020 5:25 am If your PuduanPup lacks xwininfo, a basic tool, expect many more scripts to fail, not just mine. Try with a decent distro or edit pxruler and replace the routine that detects the screen size.
Ok, yep, i will try to find out what Puduan uses to detect screen size. It is a nice pup but with some rough edges so i will see what I can find out.

Also tried some other "pups-on-trial" in my kennels and so far these results:

pxruler works in:

EoanPup
AsciiPup_7.0.0

Doesnt work in:
Puduan6.0.0 (as mentioned)

EtionaPup64_8.0.0
The ruler appears but F1 does nothing as gxmessage is missing.
# ./pxruler
sh: /usr/bin/gxmessage: No such file or directory

JRB's Quirky7 32 bit and 64bit ("April")
Both display the ruler background without divisions or numbers and both say "line 88: seq: not found" - in the terminal

(Quite a few more pups to test yet...)
QuirkyApril64_7.0.1.jpg
QuirkyApril64_7.0.1.jpg (38.17 KiB) Viewed 2264 times

Re: pxruler - measuring pixels on screen

Posted: Mon Jul 20, 2020 6:40 am
by greengeek
I am just wondering if you can offer any advice regarding how the ruler behaves on XSlackoSlim - the pxruler script icon shows up as a text file rather than a script (see pic) and if I click it it opens in a text editor.

If i change the first line to either #!/bin/bash or #!/bin/sh the icon changes to match other scripts and will run fine.

Is this something to do with incorrect mime types in this pup?

I see that ash in this pup is a symlink to busybox. Should it be something else like a symlink to bash or sh?

Re: pxruler - measuring pixels on screen

Posted: Tue Jul 21, 2020 11:29 am
by smokey01
It sounds like a mime type issue. What happens if you rename the script from pxruler to pxruler.sh?
greengeek wrote: Mon Jul 20, 2020 6:40 am I am just wondering if you can offer any advice regarding how the ruler behaves on XSlackoSlim - the pxruler script icon shows up as a text file rather than a script (see pic) and if I click it it opens in a text editor.

If i change the first line to either #!/bin/bash or #!/bin/sh the icon changes to match other scripts and will run fine.

Is this something to do with incorrect mime types in this pup?

I see that ash in this pup is a symlink to busybox. Should it be something else like a symlink to bash or sh?

Re: pxruler - measuring pixels on screen

Posted: Tue Jul 21, 2020 10:56 pm
by greengeek
Hi Smokey, thanks for the suggestion - yes if I rename the file with .sh suffix the icon changes to match the usual script icon.

Re: pxruler - measuring pixels on screen

Posted: Wed Jul 22, 2020 5:52 am
by MochiMoppel
greengeek wrote: if I rename the file with .sh suffix the icon changes to match the usual script icon.
You can add a .sh extension to any file, e.g. a JPG file, and this file will then display the script icon, without magically turning into a script. The real point is: Does the file run as a script?

Re: pxruler - measuring pixels on screen

Posted: Wed Jul 22, 2020 6:17 am
by greengeek
MochiMoppel wrote: Wed Jul 22, 2020 5:52 amYou can add a .sh extension to any file, e.g. a JPG file, and this file will then display the script icon, without magically turning into a script. The real point is: Does the file run as a script?
In this pup (XSlackoSlim 4.44) it does not run as a script with #!/bin/ash declared as it's first line. (If i click it a text editor will open the contents). If I change that first line to #!bin/bash it runs fine so this is not a script issue but a setup issue with the OS i guess.

Thanks for the information that the suffix determines the icon display. I had thought that mime types allowed Linux to understand the contents regardless of the actual suffix or file name. I think i need to research this more. Another of the things i don't understand well enough.

But i think there may be an issue with the way this pup handles (or displays) ash scripts.

ps: I predominantly use lightweight puppies in an effort to keep my old hardware alive so maybe i encounter weird stuff more than most...

Re: pxruler - measuring pixels on screen

Posted: Wed Jul 22, 2020 6:56 am
by MochiMoppel
greengeek wrote: Wed Jul 22, 2020 6:17 amIn this pup (XSlackoSlim 4.44) it does not run as a script with #!/bin/ash declared as it's first line
That's what you reported before, but the question now is: Does simply adding .sh make it execute or does it still open in an editor?
I had thought that mime types allowed Linux to understand the contents regardless of the actual suffix or file name
In principle that's correct, but ROX-Filer first checks the extension and only if there is none it will check the contents . Other tools, like the file command, don't care for the extension and check only contents. And here is where the mysteries start: ROX-Filer and other file managers report pxruler as mime type application/x-shellscript while file reports it as text/plain. I've checked the mime magic file and found no reference to ash being flagged as x-shellscript, so where does ROX-Filer gets its information from?
I predominantly use lightweight puppies in an effort to keep my old hardware alive so maybe i encounter weird stuff more than most...
All weird stuff you reported so far points to deficiencies of the distros and not to a flaw in the script. The only flaw in the script I detected so far is in the description: Moving window with keyboard moves a window by 10pixels and not 5. Sorry for that. Maybe it depends on the window manager. At least in JWM it's 10px.

Re: pxruler - measuring pixels on screen

Posted: Wed Jul 22, 2020 7:30 am
by greengeek
MochiMoppel wrote: Wed Jul 22, 2020 6:56 am ...but the question now is: Does simply adding .sh make it execute or does it still open in an editor?
Sorry i forgot to check that. I "assumed" that because it displayed like a script it must be capable of running like a script.

Just re-tested it now and yes it does run when clicked (with .sh suffix)

Re: pxruler - measuring pixels on screen

Posted: Sat Jul 25, 2020 10:04 pm
by 01micko
Works well in raspup too.

Re: pxruler - measuring pixels on screen

Posted: Sun Jul 26, 2020 9:48 am
by wiak
please move to Additional Software under the appropriate category

else

move all apps put under Additional Software into this Programming subforum...

Also, where is the program License? Without one, this is not open-source, so not contributing to open-source development process and that should be made clear to users.

Whether it works is of secondary importance compared to that - there are always alternatives out there that are open-source (just being able to read the source is far from the same as the meaning of open-source).

Re: pxruler - measuring pixels on screen

Posted: Wed Jul 29, 2020 12:15 pm
by MochiMoppel
[mention]01micko[/mention] Great.

Meanwhile I found that it basically even works in Puppy 4.2 :shock:
Needs gtkdialog3 with all its limitations (doesn't understand key codes, so no rotation, no ESC and no F1), but SVG supported and horizontal ruler no problem.

BTW: I added a suitable 48x48 icon to the original post.

Re: pxruler - measuring pixels on screen

Posted: Wed Jul 29, 2020 3:05 pm
by 666philb
hi [mention]MochiMoppel[/mention] ,

in fossapup64 i had to edit line 61 to get it to work

Code: Select all

	echo -n '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" shape-rendering="crispEdges" width="'$RULERWIDTH'" height="'$RULERHIGHT'" '$ROT_STRING'>
there were issues in woofce also due to newer svg libs https://github.com/puppylinux-woof-CE/w ... ssues/1806

Re: pxruler - measuring pixels on screen

Posted: Wed Jul 29, 2020 6:29 pm
by rockedge
[mention]MochiMoppel[/mention] I really like using this tool and mm_view so I include them in my WeeDog builds.
I do not see anything prohibiting me from doing this. We could discuss licenses but I am not a lawyer and since none of this is making me any money at all I will continue to do so without remorse.

If I do indeed at some time become a wealthy person and your code is involved, I'll give you a fair share. Otherwise if I see it and it works I'm using it.

Don't hold your breath waiting for me to become wealthy, that ship has sailed.

The pxruler is very helpful in CSS design I find.

Re: pxruler - measuring pixels on screen

Posted: Sun Aug 02, 2020 3:17 am
by MochiMoppel
666philb wrote: Wed Jul 29, 2020 3:05 pm in fossapup64 i had to edit line 61 to get it to work

Code: Select all

	echo -n '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" shape-rendering="crispEdges" width="'$RULERWIDTH'" height="'$RULERHIGHT'" '$ROT_STRING'>
there were issues in woofce also due to newer svg libs https://github.com/puppylinux-woof-CE/w ... ssues/1806
Hi [mention]666philb[/mention] Does this also affect images where namespace declarations are not really needed, like the ones I use in mm_view, where I try to omit unnecessary declarations? They *should* still work.

And since in pxruler I use only the xlink attribute, would following line be suffient?

Code: Select all

echo -n '<svg xmlns:xlink="http://www.w3.org/1999/xlink" shape-rendering="crispEdges" width="'$RULERWIDTH'" height="'$RULERHIGHT'" '$ROT_STRING'>


[mention]rockedge[/mention] Fear not :) I'm glad to know that it is useful for you. If it ever makes you rich, keep the money but promise to send me a postcard from the Bahamas.

Re: pxruler - measuring pixels on screen

Posted: Sun Aug 02, 2020 11:43 am
by 666philb
MochiMoppel wrote: Sun Aug 02, 2020 3:17 am
Hi @666philb Does this also affect images where namespace declarations are not really needed, like the ones I use in mm_view, where I try to omit unnecessary declarations? They *should* still work.

And since in pxruler I use only the xlink attribute, would following line be suffient?

Code: Select all

echo -n '<svg xmlns:xlink="http://www.w3.org/1999/xlink" shape-rendering="crispEdges" width="'$RULERWIDTH'" height="'$RULERHIGHT'" '$ROT_STRING'>

hi [mention]MochiMoppel[/mention] ,

yes that line fixes it.
i gave mm_view a try and and it renders svgs fine. is there any other specific thing to test in mm_view?

Re: pxruler - measuring pixels on screen

Posted: Tue Aug 04, 2020 8:59 am
by MochiMoppel
666philb wrote: i gave mm_view a try and and it renders svgs fine. is there any other specific thing to test in mm_view?
Hi [mention]666philb[/mention] Thanks. I'm not sure if you have the latest version (0.31), so I downloaded fossapup and tried myself. The leftclick option of the SEL button works fine, the rightclick "Zoom" option does not.
Problems with gxmessage:
1) minor point: I use the -title option but the Group option in .jwmrc forces all "xmessage" windows to display without title. Makes no sense to me. A user of gxmessage can use the -borderless option if he wants to have no window decoration. I do this often, but I still want to have the choice. The Group setting deprives me of this choice

2) Your gxmessage version 2.20.14 behaves differently from my version 2.12.4.
Try this:

Code: Select all

 gxmessage -geo 500x-1 -fn 128 "123456789012345678"
Displays a long string with huge font size 128, limits window width to 500px. Since gxmessage by default expands the height to accomodate content, I set the the height value to -1, which in my version is interpreted as "let gxmessage find the suitable height". This is not understood in version 2.20.4 and gxmessage sets the height to minimum value (150px), much too small for the font.

Re: pxruler - measuring pixels on screen

Posted: Wed Aug 05, 2020 6:01 pm
by 666philb

@MochiMoppel thanks i'll use the older gxmessage for fossapup.
BTW where's your latest mm_view located?


Re: pxruler - measuring pixels on screen

Posted: Thu Aug 06, 2020 7:34 am
by Keef
The change happened in gxmessage 2.20.2. Maybe the 'home-rolled' was better than he thought.
Here is part of the ChangeLog:

Code: Select all


2015-05-21  Tim Musson  <trmusson@gmail.com>

    * configure.ac: Version to 2.20.2

    * gxmessage.c: Replaced our home-rolled geometry parser with the now
      working gtk_window_parse_geometry().

    * doc/gxmessage.1, doc/gxmessage.texi: Updated documentation.

    * compile, depcomp, install-sh, INSTALL: Latest versions from gnulib.

    * patches/*: As documentation, contributed patches are now distributed
      with the package. See AUTHORS.

Re: pxruler - measuring pixels on screen

Posted: Fri Aug 07, 2020 4:36 am
by MochiMoppel
666philb wrote: Wed Aug 05, 2020 6:01 pm

@MochiMoppel thanks i'll use the older gxmessage for fossapup.

No, please keep the new version, I will update mm_view and make it compatible with all versions. The new gxmessage has a -ontop option, which - if it works - makes it possible to pop-up a message on top of fullscreen windows. Very useful for alerts.

The issue with the JWM Group setting may be more important. See my post in the Fossapup64 thread

BTW where's your latest mm_view located?

On the Murga forum 😢...and on my 💻
I still hope that the Murga stuff can be resurrected and keep my fingers crossed. If you need a copy of the file just drop me a line.

@Keef I agree that the home-rolled parser was better but I'm not sure if my usage was documented or even intended. It just happens to work nicely


Re: pxruler - measuring pixels on screen

Posted: Mon Aug 10, 2020 6:49 am
by greengeek
Thanks for this utility MochiMoppel - now that i have started using it daily across multiple puppies i find it invaluable particularly when setting up parameters for screengrab utilities - no more guessing x and y values for the portion of a window i am interested in capturing.
Cheers!

pxruler 2.0

Posted: Fri Oct 22, 2021 4:34 am
by MochiMoppel

Update to version 2.0 (see initial post)

version 2.0 adds an option that allows to measure distances manually by clicking 2 points on screen

Screenshot.png
Screenshot.png (5.98 KiB) Viewed 1951 times