eprev / eprev.org

That’s my spot.
https://eprev.org
5 stars 1 forks source link

Comments: Converting PNG to SVG #10

Open eprev opened 7 years ago

eprev commented 7 years ago

This issue is reserved for comments on Converting PNG to SVG.

mandarvaze commented 6 years ago

I tried the same for JPG, and the resultant SVG looks huge when opened in the browser (firefox) Even after Cmd+- (Zoom out - stops at 30%) I can't see the entire image in my screen.

I'm referring to this image if it matters.

command used :

convert -alpha remove timoy.jpg pgm: | mkbitmap -f 32 -t 0.4 - -o - | potrace --svg -o timoy.svg

I can't attach the generated SVG for your reference, since github does not support attaching SVG.

eprev commented 6 years ago

You can play with --width argument (sets width in points, pt) of the potrace command:

convert -alpha remove timoy.jpg pgm: | mkbitmap -f 32 -t 0.4 - -o - | potrace --svg --width 10 -o timoy.svg

Or simple change width and height attributes of the generated SVG manually.

mandarvaze commented 6 years ago

Thanks, Works well. 10 was still a little too big for my laptop screen.5 or 6 worked well. -r300 also worked to get "decent" sized image.

I tried the same command (without any extra params) on the sample PNG from your blog. The size of SVG is still bigger than PNG.

Does the "default" size of SVG (without specifying width or r) depend upon the original size of input file ? (PNG or JPG)

In my case, the original JPG itself are big, may be that is why SVG are HUGE (visual size wise)

eprev commented 6 years ago

I don't know how it calculates the default size, but I always set desired width and heigh in the generated SVG by editing it.

mandarvaze commented 6 years ago

Aha, Thanks.

bhavikshah1995 commented 5 years ago

I get the error 'Invalid parameter remove' when trying to run the first command of the 3 mentioned on Converting PNG to SVG. I'm a bit of a rookie so I don't know what is going wrong.

eprev commented 5 years ago

Make sure you have ImageMagick 6.7.5+ installed.

1ofseven commented 5 years ago

My attempt resulted in two errors (using imagemagick-6.9.10_53-x86_64-1) $ convert -alpha remove gog_com.png pgm: | mkbitmap -f 32 -t 0.4 - -o - | potrace --svg -o gog_com.svg mkbitmap: -: empty file potrace: stdin: empty file

This results in a zero byte file: gog_com.svg Note that the input png is a colored image. Also, the following will generate a file of the same byte size as the input file: $ convert -alpha remove gog_com.png pgm: Thanks for any insight. Update: Removing the pipes did produce a b/w svg file. $ convert -alpha remove gog_com.png ppm:temp.ppm $ mkbitmap -f 32 temp.ppm -o temp.bmp $ potrace --svg temp.bmp -o gog-com.svg

eprev commented 5 years ago

Hey, @1ofseven, sorry, don't know why piping isn't working for you. Glad you figured the workaround out.

1ofseven commented 5 years ago

Yeah, pretty weird. Thanks for replying.

On 14:08, Thu, Jul 18, 2019 Anton Eprev <notifications@github.com wrote:

Hey, @1ofseven https://github.com/1ofseven, sorry, don't know why piping isn't working for you. Glad you figured the workaround out.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/eprev/eprev.org/issues/10?email_source=notifications&email_token=AJJOSLUBLDXEQL4SOAQGXWLQACWSVA5CNFSM4C2YQLF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JKEJY#issuecomment-512926247, or mute the thread https://github.com/notifications/unsubscribe-auth/AJJOSLXSB5A7II25LRRIO6DQACWSVANCNFSM4C2YQLFQ .