migvel / color_trace Goto Github PK
View Code? Open in Web Editor NEWTraces multiple color images using potrace. This is similar to Inkscape's Trace Bitmap function.
License: GNU General Public License v2.0
Traces multiple color images using potrace. This is similar to Inkscape's Trace Bitmap function.
License: GNU General Public License v2.0
I'm passing the following command to convert a JPG to SVG but it's not generating any new file in the output directory:
python3 color_trace_multi.py --input="/content/logo.jpg" --output="/content/color-results" --colors=2
When providing an output path without quotes, the program does not recognize the argument. When quotes are provided when the output file is saved in the wrong directory, because the quotes are interpreted as part of the path.
I am not a python expert but this way it works just fine
Add this code to the main function ( def main(args=None): ) to line 883:
output_pattern =output_pattern.strip('\"\'')
inputs_outputs = zip(*get_inputs_outputs(args.input, output_pattern))
This will let the script work with long paths quoted.
After that the script can be called with quotes without problems e.g. :
python3 color_trace_multi.py -i "path1" -o "path2" -q as -c 32 -s
I'm trying to run the windows version, with this command line:
color_trace_multi -i png\*.png -o svg\* -c 0
But al i got is this error:
[Errno 2] No such file or directory: 'svg\\accept~tmp_scaled.png'
The path svg is created and accessible, so i can't figure out the error...
Can anybody help on this one?
Thanks
Hi, I would like to use this in windows. Wondering if there is a binary release or .exe already built?
When i submit a transparent background .png, the background results all black
Hi guys,
White color is getting automatically converted to transparent (removed)
Is it possible to preserve it?
Thank you
Regards,
python script gives below error while o convert gif to svg
Process color_trace worker #2:
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/var/www/html/apps/server/src/../public/color_trace/color_trace_multi.py", line 748, in process_worker
q1_job(q2, total, layers, settings, **job_args)
File "/var/www/html/apps/server/src/../public/color_trace/color_trace_multi.py", line 641, in q1_job
raise e
File "/var/www/html/apps/server/src/../public/color_trace/color_trace_multi.py", line 615, in q1_job
quantize(this_scaled, this_reduced, settings['colors'], algorithm=settings['quantization'], dither=settings['dither'])
File "/var/www/html/apps/server/src/../public/color_trace/color_trace_multi.py", line 141, in quantize
with open(src, 'rb') as srcfile:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpwb9prs3z/0~scaled.png'
Hi,
in my ubuntu os, i tried with
python3 /var/www/html/apps/color_trace/color_trace_multi.py -i /var/www/html/apps/color_trace/test.png -o /var/www/html/apps/color_trace/after.svg -c 8
but its gives error
color_trace_multi.py: error: argument -i/--input: expected at least one argument
Hi,
the only way I get any vectorizing done by this is script is using -c 0 option, if I change the value to anything else, I get just "Tracing complete!" but no output... Could you explain please?
Is there a way to omit the BG from the SVG?
Hello!
Could someone paste the command they're running in their terminal when working on a Windows machine? I haven't been able to get mine to run without errors and I can't tell if it's because I don't understand the formatting of the run command or if something is actually wrong. Thanks so much!
Hello;
the module threw "TypeError: can't pickle weakref objects" today at line 801 p.start()
As I have only very simple graphics (black + white + transparent), is it possible without greater rework, to remove the multiprocessing?
I took a look at your code today and it seems to be a big part of your code.
Here's a dump of the error trace
my code:
ctm.color_trace_multi(inputs=picpath,
outputs=outpath,
colors = 1,
processcount = 1)
error:
Traceback (most recent call last):
File "", line 4, in
processcount = 1)
File "C:\Users\Andreas\25 Heroquest\Questimator\Code\Multicolor_Symbols\color_trace_multi.py", line 801, in color_trace_multi
p.start()
File "C:\Users\Andreas\Anaconda3\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "C:\Users\Andreas\Anaconda3\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\Andreas\Anaconda3\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "C:\Users\Andreas\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 65, in init
reduction.dump(process_obj, to_child)
File "C:\Users\Andreas\Anaconda3\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
python3 color_trace_multi.py -v -i page.bmp -r remap.png -o out.svg
yields:
unsupported operand type(s) for *: 'int' and 'NoneType'
.
EDIT
Hello,
i had some problems to use color_trace, the main problem was that i was using python
in the terminal instead of python3
!
The correct syntax for me is:
linux@pop-os:~/Downloads/color_trace-master$ python3 color_trace_multi.py -i test.png -o test.svg -c 8
Tracing complete!
Thank you for the project!
Best explained with a demonstration:
[stephan@host:~/src/color_trace]$ ./color_trace_multi.py
/usr/bin/env: ‘python\r’: No such file or directory
\r characters are Evil.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.