Re: Measure tool (feature proposition)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, Aug 26, 2009 at 11:14 AM, Adam Majewski<am@xxxxxxxxxxxxx> wrote:
>  If someone will have solution i am interested in!

I just hacked my path measurement plug-in to handle this.  You need
gimp-python.  Once it's installed:

1. Draw a path with the pen tool over what needs to be measured.
2. Filters->Measure->Active  Path
    - Enter pixels (integer) from the ratio in the first box, and
units (integer) in the second box (eg, meters).

Then look in the Error console for output.  Did not test it much - let
me know if it works out...

HTH,
Chris
#!/usr/bin/env python
# Author: Chris Mohler
# Copyright 2009 Chris Mohler
# License: GPL v3
# Version 0.3
# GIMP plugin to measure the length of a path

from gimpfu import *

gettext.install("gimp20-python", gimp.locale_directory, unicode=True)


def measure_path(img, drw, pixels, units):
    try:
	path = pdb.gimp_image_get_active_vectors(img)
	len = pdb.gimp_vectors_stroke_get_length(path, 1, 1)
	len = int(len)
	if pixels != 0 and units!=0:
	    len = int((len/pixels)*units)
	    pdb.gimp_message("Length of " + path.name + ": " + str(len) + " units")
	else:
	    pdb.gimp_message("Length of " + path.name + ": " + str(len) + " px")
	
	    
    except:
	pass
    
register(
    proc_name=("python-fu-measure-path"),
    blurb=("Measure Path"),
    help=("Measure Length of the active path.  Output is directed to the Status Bar or Error Console."),
    author=("Chris Mohler"),
    copyright=("Chris Mohler"),
    date=("2009"),
    label=("Active Path"),
    imagetypes=("*"),
    params=[
	(PF_IMAGE, "img", "Image", None),
	(PF_DRAWABLE, "drw", "Drawable", None),
	(PF_INT, "pixels", "Pixels", 0),
	(PF_INT, "units", "Units", 0)
	   ],
    results=[],
    function=(measure_path), 
    menu=("<Image>/Filters/Measure"), 
    domain=("gimp20-python", gimp.locale_directory)
    )

main()
_______________________________________________

Gimp-user@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

[Index of Archives]     [Gimp Announce]     [Gimp GUI]     [Gimp Images]     [GIMP Development]     [Video For Linux]     [Photos]     [Yosemite News]     [Yosemite Photos]     [gtk]     [KDE]     [Scanners]     [Gimp's Home]     [Gimp Docs]     [Gimp on Windows]     [Steve's Art]     [Webcams]     [Share Your Images]     [Script Fu]     [GIMP Software]     [GIMP Books]

  Follow Gimp on Twitter