It is currently Tue Apr 30, 2024 4:40 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 19 posts ] 
Author Message
 Post subject: Using Potrace
PostPosted: Thu Feb 17, 2011 3:32 pm  (#1) 
Offline
GimpChat Member

Joined: Nov 18, 2010
Posts: 8
can anyone tell me how to install potrace? ive downloaded the files and stuck them in c:/windows and execute the files but only prompt appears with black box! do i have to use thro gimp? thanks


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 3:39 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12518
Here's a batch file that I created to use with Potrace; just copy it in your Potrace directory (save it as pt.bat if you like). Your bitmap has to be a BMP file (not PNG, or anything else; well, it could be a pgm, pbm, or ppm too). Just copy a shortcut to your desktop and then drag a bitmap file on top of it and release. You will get an SVG result to use whereever you want to use it in. :)

potrace -r 72 -t .2 -x 1 -a 0.85 -s %1

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 4:23 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2249
Location: Poland
This is in its simplicity a beautiful and brilliant - because it works - and for autotrace?

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 4:57 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12518
Here's a batch file (script if you will) that I use with Autotrace. I actually use to use 4 different ones depending on how accurate I want the result to me (more accurate means longer time to process; to get more accuracy, lower the despeckle-level entry {wouldn't go below 4}). Now I just use this result and blend with original bitmap for vector simplication. Now Autotrace won't work with my Win7 64-bit OS for whatever reason, but still works perfectly fine with my XP VM. :)

AUTOTRACE -corner-threshold 75 -despeckle-level 16 -despeckle-tightness 2 -output-format svg -output-file %1+a.svg -report-progress %1

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 5:27 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Thanks Lyle I have been trying to get these to work as well. :bigthup

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 6:09 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
A couple of example SVG's created with your bat files added Lyle (thank you so very much)
one of potrace black and white
One of color (autotrace)

Image

Image

Very nice

I use Vextractor Pro, and VectorMagic too.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 7:46 pm  (#7) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Lyle: Your autotrace batch brings up an ugly result for me. Inkscape does a far better job. Are you following a set of steps before running this or just running it on an image as is?

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 8:29 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12518
Play with the despeckle value (no smaller then 4) which will give higher quality result. Need to compensate for the transparent gaps as I inferred with that post. I usually blend a copy of the original and do some additional cleanup steps for vector simplication (main reason I still use Autotrace). In Inkscape, you could try to grow the blocks together to fill in the voids. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 10:36 pm  (#9) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Lowering despeckle didn't actually improve the image when I tried it. I took the same image and dropped it in Inkscape and got a fairly decent (not perfect) vector. I feel like there's a switch missing in this string, because all output, changing only the despeckle setting = crappy looking.

Can I ask what image types you use when using Autotrace? Input, not output.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 11:15 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12518
Inkscape added a few additional features that help blend the seams better that are not available in Autotrace alone. Best to just use Inkscape for a gui vector program, but I actually do like the output from Autotrace with blending in GIMP. To eaches own. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 11:21 pm  (#11) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Lyle:

I'm not complaining, nor claiming Inkscape as a better alternative. Far from it. I'm trying to find the best setting for it (autotrace via command line) hard to fidget with something you can't see happening til it happens. Installing the KDE front end helped sort that out, though, whew!

Also, potrace rocks, man! I love that little utility.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 11:28 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12518
Didn't mean to come across crass Mahvin. I do agree with you about Potrace. I actually use to like feed three diffent contrast blends from Potrace output with different Opacities to get a multi-tone vexel result. Still, only so many type of looks you can get with vector simplication. I still like using other programs (DAP and PostworkShop to name a few) for addition forms of simplication. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Using Potrace
PostPosted: Thu Feb 17, 2011 11:55 pm  (#13) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
I think half the fun is finding something that works favorably when you're just fiddling around. It's all good (win-win)

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Using Potrace
PostPosted: Fri Feb 18, 2011 8:56 am  (#14) 
Offline
GimpChat Member

Joined: Nov 18, 2010
Posts: 8
thats great thanks - i need to summarise this now - forgive my incompetence so far!

1-download potrace folder for win32 and place it in c:/windows
2-create a batch file (how?) is it a .txt file with your code pasted in and then i rename it including the file extension to pt.bat??
3-create a shortcut of (what?) potrace.exe from within the downloaded folder or of the batch file i just created? and place on desktop
4-drag a bmp onto the shortcut

with these answers i think im there, thanks!


Top
 Post subject: Re: Using Potrace
PostPosted: Fri Feb 18, 2011 12:01 pm  (#15) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12518
OK; once you create your batch file (pt.bat; needs to be in the same directory where your Potrace executible is located at), you copy a shortcut to it on your desktop (copy/paste shortcut). Now all you have to do is drag your bitmap target on top of the shortcut and it will create the svg file (a little lazy with the batchfile; might want to rename the file if you need to; lol). :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Using Potrace
PostPosted: Tue Apr 05, 2011 12:58 pm  (#16) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2249
Location: Poland
lylejk wrote:
Here's a batch file that I created to use with Potrace; just copy it in your Potrace directory (save it as pt.bat if you like). Your bitmap has to be a BMP file (not PNG, or anything else; well, it could be a pgm, pbm, or ppm too). Just copy a shortcut to your desktop and then drag a bitmap file on top of it and release. You will get an SVG result to use whereever you want to use it in. :)

potrace -r 72 -t .2 -x 1 -a 0.85 -s %1


Using XNViewShell can and png ...


Attachments:
TRACE_LYLE.ZIP [2.56 KiB]
Downloaded 137 times
Trace 1.png
Trace 1.png [ 739.34 KiB | Viewed 2587 times ]
Trace 2 -svg-potrace-in Gimp.png
Trace 2 -svg-potrace-in Gimp.png [ 82.38 KiB | Viewed 2587 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: Using Potrace
PostPosted: Tue Apr 05, 2011 1:17 pm  (#17) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2249
Location: Poland
Trace_Lyle.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
call an external program passing the active layer as a temp file.  Windows Only

Author:
Rob Antonishen

Version:
0.4 modified to support many optional programs.
this script is modelled after the mm extern LabCurves trace plugin
by Michael Munzert http://www.mm-log.com/lab-curves-gimp
and thanks to the folds at gimp-chat has grown a bit ;)
License:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
The GNU Public License is available at
http://www.gnu.org/copyleft/gpl.html

'''

from gimpfu import *
import shlex
import subprocess
import os, sys
import tempfile

#program list function (globals are evil)
def listcommands(option=None):

  programlist = [
  ["Autotrace", "\"C:\\Program Files\\Autotrace\\autotrace_lyle.bat\""],  #<<<-----SET ME<<<----- (Directory where you place your bat)
  ["Potrace", "\"C:\\Program Files\\Potrace\\potrace_lyle.bat\"", "bmp"], #<<<-----SET ME<<<----- (Directory where you place your bat)
  ["",""]
  ]
 
  if option == None: # no parameter return menu list, otherwise return the appropaiate array
    menulist = []
    for i in programlist:
      if i[0] != "":
        menulist.append(i[0])
    return menulist
  else:
    return programlist[option]
   

def plugin_main(image, drawable, command):
  pdb.gimp_image_undo_group_start(image)

  temp = pdb.gimp_image_get_active_drawable(image)
  buffer = pdb.gimp_edit_named_copy(temp, "ShellTemp")

  #save selection if one exists
  hassel = pdb.gimp_selection_is_empty(image) == 0
  if hassel:
    savedsel = pdb.gimp_selection_save(image)

  tempimage = pdb.gimp_edit_named_paste_as_new(buffer)
  pdb.gimp_buffer_delete(buffer)
  if not tempimage:
    raise RuntimeError
  pdb.gimp_image_undo_disable(tempimage)

  tempdrawable = pdb.gimp_image_get_active_layer(tempimage)

  # Use temp file names from gimp, it reflects the user's choices in gimp.rc
  # change as indicated if you always want to use the same temp file name
  tempfilename = pdb.gimp_temp_name("bmp")
  #tempfilename = os.path.join(tempfile.gettempdir(), "SheTempFile.bmp")
 

  # !!! Note no run-mode first parameter, and user entered filename is empty string
  pdb.gimp_progress_set_text ("Saving a copy")
  pdb.file_bmp_save(tempimage, tempdrawable, tempfilename, tempfilename)

  # Command line - Change to match where you installed XnView
  progtorun = listcommands(command)
  command = progtorun[1] + " \"" + tempfilename + "\""
  args = shlex.split(command)

  # Invoke external command
  pdb.gimp_progress_set_text ("calling " + progtorun[0] + "...")
  pdb.gimp_progress_pulse()
  child = subprocess.Popen(args, shell=False)
  child.communicate()

  #load up old selection
  if hassel:
    pdb.gimp_selection_load(savedsel)
    image.remove_channel(savedsel)
 
  # cleanup
  os.remove(tempfilename)  # delete the temporary file
  gimp.delete(tempimage)   # delete the temporary image

  # Note the new image is dirty in Gimp and the user will be asked to save before closing.
  pdb.gimp_image_undo_group_end(image)
  gimp.displays_flush()


register(
        "python_fu_shelloutsvg",
        "Save as SVG in Gimp/tmp directory",
        "Call an Trace program",
        "Rob Antonishen",
        "Copyright 2011 Rob Antonishen",
        "2011",
        "<Image>/File/Eksport image as svg...",
        "RGB*, GRAY*",
        [ (PF_OPTION,"command",("Program:"),0,listcommands())
        ],
        [],
        plugin_main,
        )

main()

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Using Potrace
PostPosted: Fri May 06, 2011 3:23 pm  (#18) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2249
Location: Poland
For holders of Linux is yet another old program (but it works in Ubuntu 11.04)
Potracegui
http://pkgs.org/debian-lenny/debian-main-i386/potracegui_1.3-2.3_i386.deb.html
http://pkgs.org/debian-lenny/debian-main-amd64/potracegui_1.3-2.3_amd64.deb.html
The Gimp (ShellOut) can only be indirect call - then copy -> paste


Attachments:
Potracegui.png
Potracegui.png [ 399.01 KiB | Viewed 2530 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: Using Potrace
PostPosted: Fri May 06, 2011 8:26 pm  (#19) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
I tried your python file in Gimp-2.6.11 and it didn't work for me.It looks like its doing something and it creates a svg file in local settings/temp but the file is not usable. (it will not open).

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
Post new topic Reply to topic  [ 19 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Plugin Potrace

11

No new posts Attachment(s) error when running potrace

2

No new posts Attachment(s) Potrace with LIVE PREVIEW

0



* Login  



Powered by phpBB3 © phpBB Group