Export selected groups as PNG's

Post questions on how to use or achieve an effect in Inkscape.
User avatar
Lucas?
Posts: 13
Joined: Wed Jun 26, 2013 10:46 am

Export selected groups as PNG's

Postby Lucas? » Wed Jun 26, 2013 11:28 am

Hello everyone. I'm new here, but I've been using Inkscape for a good while. By the way, I love it! It's such an awesome program!
(sorry about english mistakes on this post, if there are any)

Okay, here's my situation:
I'd like to know how to export all the selected GROUPS of objects in my Inkscape drawing as their own PNG's each having:
  • The same widht and height of the page
  • Transparent background
  • The object in the same position as it appears on the page

I tried searching for an answer on this subject but I found only pointers for using the "Export in group all the selected objects" on the "Export Bitmap" window.
This however, didn't make what I wanted it to do (what I said before). Also, I couldn't control the folder which the PNG's should be exported to.

So, what should I do in order to achieve this? =/

Thank you.
Last edited by Lucas? on Sat Jan 11, 2014 12:19 pm, edited 6 times in total.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Export selected groups as PNG's

Postby Lazur » Thu Jun 27, 2013 7:02 am


User avatar
Lucas?
Posts: 13
Joined: Wed Jun 26, 2013 10:46 am

Re: Export selected groups as PNG's

Postby Lucas? » Thu Jun 27, 2013 11:13 am

Many thanks for your kindness!

Well, I tried out this guillotine extension, but it didn't work as I expected though. It exported only one image (I want various images, each one for a group) and with all the objects on it. In short, it wasn't different from using the normal export window =P

Then I downloaded that svg-objects-export. It looks promising. But how in the world do I use it? I have no idea =P

Anyway, to put it simple, what I need could be basically an automated way of transfering the selected groups into individual layers and then page-exporting (i. e. Export Bitmap->Page...) all those layers into their own PNG's.

So?

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Export selected groups as PNG's

Postby Lazur » Fri Jun 28, 2013 12:21 am

If you are familiar with python, you can surely write an extension for that.
May Ragnar appear and give some good advices!

User avatar
Lucas?
Posts: 13
Joined: Wed Jun 26, 2013 10:46 am

Re: Export selected groups as PNG's

Postby Lucas? » Fri Jun 28, 2013 3:56 am

Thank you again.

Of course, I could write an extension for that. But I'm not familiar with Python. I'm familiar only with C, C++ and Assembly. Maybe I could write a plugin (DLL)? But I think that would be for adding new functionalities into Inkscape, and what I want is just automating a process.

I really hope there's already an extension for what I'm aiming out there.

But I made some progress. In the last post I mentioned:
Anyway, to put it simple, what I need could be basically an automated way of transfering the selected groups into individual layers and then page-exporting (i. e. Export Bitmap->Page...) all those layers into their own PNG's.

I actually came with a better idea: to put it MORE simple, it could be an automated process of selecting a group, then Export->Page it with the checkbox "Hide All except selected" marked up; And then repeating the same process for each other group.

Thanks again anyway.

User avatar
Lucas?
Posts: 13
Joined: Wed Jun 26, 2013 10:46 am

Re: Export selected groups as PNG's

Postby Lucas? » Sat Jun 29, 2013 9:39 am

(Sorry for the double post, I don't know if this is forbidden on this forum, the rules didn't state anything about it... So here I am)
Okay, guess what.

I've had an idea.
I discovered I actually can achieve what I want with C++.

So what I'm going to do is build a program which will give automated batch commands to Inkscape for exporting all the groups of objects to separate PNG's. The user will just need to provide the path of Inkscape, the path of the SVG they desire to do the process with, the destination path to save the PNG's and the exporting mode (either page or drawing).

Thanks for the help anyway Lazur UHR.
I should share the program here with you people once it's finished.
Last edited by Lucas? on Sat Jan 11, 2014 12:16 pm, edited 2 times in total.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Export selected groups as PNG's

Postby Lazur » Sat Jun 29, 2013 9:46 am

That sounds great!
If only I could code on a high level...
Will post some day my thoughts for some new features anyway soon.

User avatar
Lucas?
Posts: 13
Joined: Wed Jun 26, 2013 10:46 am

Re: Export selected groups as PNG's

Postby Lucas? » Sat Jun 29, 2013 10:08 am

Lazur URH wrote:That sounds great!
If only I could code on a high level...
Will post some day my thoughts for some new features anyway soon.

But you can code on a high level (not really sure of what you mean by "high level", because there are different meanings for that when it comes to programming. Whatever) if you want so. You just need to have the time and desire to learn. It's not anything impossible. That is, if you are really interested on coding.

I plan to distribute the source code together with the program, so you people can have a look at it or whatever else.
Last edited by Lucas? on Sat Jan 11, 2014 12:15 pm, edited 1 time in total.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Export selected groups as PNG's

Postby Lazur » Sat Jun 29, 2013 10:30 am

Yes, everything is possible but is it really necessary to learn how to speak ancient greek, just to buy a bread from the bakery?
Desire is relative but the value of the result is even more problematic.
I can't see how much work would it take -something like writing a new specification similar to the svg?

BetaTestingPro
Posts: 38
Joined: Mon Aug 15, 2011 3:27 am

Re: Export selected groups as PNG's

Postby BetaTestingPro » Mon Jul 01, 2013 3:57 am

Lucas? wrote:(Sorry for the double post, I don't know if this is forbidden on this forum, the rules didn't state anything about it... So here I am)
Okay guys, guess what.

I've had an idea.
I discovered I actually can achieve what I want with C++.

So what I'm gonna do is build a program which will give automated batch commands to Inkscape for exporting all the groups of objects to separate PNG's. The user will just need to provide the path of Inkscape, the path of the SVG they desire to do the process with, the destination path to save the PNG's and the exporting mode (either page or drawing).

Thanks for the help anyway Lazur UHR.
I should share the program here with you guys once it's finished.


Maybe I don't understand what you are trying to achieve, but it seems to me that you could do what you want by using the Web > Slicer > Create a Slicer Rectangle and in the "Create a Slicer Rectangle" box use the Force Dimension box to force the Dimensions you want. Then perhaps select the group of objects and use Web > Slicer > Set a Layout Group until you have everything you want exported setup with the Slicer Rectangles and Layout Groups. Then use Web > Slicer > Export Layout Pieces and HTML + CSS Code.

For what you want, you may not need the HTML + CSS Code, but this would at least let you FORCE the DIMENSIONS that you are after. Plus, it should also allow you to choose a folder to export to as well.

Or like I said above, maybe I'm just confused and don't understand what it is you are trying to achieve.

In any case, if you do create a plugin to do what you are trying to do, I'll be looking forward to trying it out. I just hope it would work on Ubuntu but I'm not so sure since you mentioned using DLLs in your previous post.

Anyway, good luck and let us know how you get on with it. :)

User avatar
Lucas?
Posts: 13
Joined: Wed Jun 26, 2013 10:46 am

Re: Export selected groups as PNG's

Postby Lucas? » Mon Jul 01, 2013 9:05 am

Many thanks BetaTestingPro!

BetaTestingPro wrote:Maybe I don't understand what you are trying to achieve, but it seems to me that you could do what you want by using the Web > Slicer > Create a Slicer Rectangle and in the "Create a Slicer Rectangle" box use the Force Dimension box to force the Dimensions you want. Then perhaps select the group of objects and use Web > Slicer > Set a Layout Group until you have everything you want exported setup with the Slicer Rectangles and Layout Groups. Then use Web > Slicer > Export Layout Pieces and HTML + CSS Code.

For what you want, you may not need the HTML + CSS Code, but this would at least let you FORCE the DIMENSIONS that you are after. Plus, it should also allow you to choose a folder to export to as well.

I tried it out on a SVG containing 2 groups with 2 objects each. I don't know if I did something wrong, but what I've got were 4 files (there should be only 2, each for a group) and totally blank.

Anyway, I'm just finnishing the development of my C++ program to solve the problem. It should be done in a few hours or maybe tomorrow. Things are going pretty well :P

BetaTestingPro wrote:In any case, if you do create a plugin to do what you are trying to do, I'll be looking forward to trying it out. I just hope it would work on Ubuntu but I'm not so sure since you mentioned using DLLs in your previous post.

It's actually not a plugin, but an ordinary executable file indeed ;) Man, I'm so thankful for your interest on trying it out! It really motivates me :) But I'm sorry... I won't be building an Ubuntu version for this program :| I forgot to say that, but my OS is Windows 7, and I'm using Windows API functions like MessageBox() and ShellExecute() to make the program. And I never used Ubuntu before, so I have no idea of the libs I'd must use in order to build for that platform. Also I don't have a compiler for it. However, I'll be releasing the source code along, so maybe someone can modify the platform dependent lines in order to make it avaliable for other platforms as well. Though for me, there's no warranty of course. I'm really sorry to disappoint :oops: But again, you really motivated me.

BetaTestingPro
Posts: 38
Joined: Mon Aug 15, 2011 3:27 am

Re: Export selected groups as PNG's

Postby BetaTestingPro » Mon Jul 01, 2013 12:14 pm

Lucas? wrote:Many thanks BetaTestingPro!


No problem Lucas, I was hoping my idea would help you, but it sounds like you are doing great with your own code which will be awesome for you and others I'm sure!

Lucas? wrote:I tried it out on a SVG containing 2 groups with 2 objects each. I don't know if I did something wrong, but what I've got were 4 files (there should be only 2, each for a group) and totally blank.


Hmmmm? Well, I tried to give advice that I thought would work. Sorry it did not work out for you. I only hope it didn't waste too much of your time. ;)

Lucas? wrote:Anyway, I'm just finnishing the development of my C++ program to solve the problem. It should be done in a few hours or maybe tomorrow. Things are going pretty well :P


Well, that sounds great and though I'm NOT a C++ programmer myself, I'm certainly not against looking at your source code and trying to compile it myself for Ubuntu. And even if I can't do it, I may know someone who can.

BetaTestingPro wrote:In any case, if you do create a plugin to do what you are trying to do, I'll be looking forward to trying it out. I just hope it would work on Ubuntu but I'm not so sure since you mentioned using DLLs in your previous post.


Lucas? wrote:It's actually not a plugin, but an ordinary executable file indeed ;) Man, I'm so thankful for your interest on trying it out! It really motivates me :) But I'm sorry... I won't be building an Ubuntu version for this program :| I forgot to say that, but my OS is Windows 7, and I'm using Windows API functions like MessageBox() and ShellExecute() to make the program. And I never used Ubuntu before, so I have no idea of the libs I'd must use in order to build for that platform. Also I don't have a compiler for it. However, I'll be releasing the source code along, so maybe someone can modify the platform dependent lines in order to make it avaliable for other platforms as well. Though for me, there's no warranty of course. I'm really sorry to disappoint :oops: But again, you really motivated me.


I'm glad I could motivate you to go ahead and git er done in any case.... even if I can't use it. It still makes me happy that you are motivated enough to do it for yourself and other Windows users, which I imagine is the majority of Inkscape users anyhow. That said, I do still have WinXP on an older computer and I may be able to try it out on that PC. Though I haven't even booted that thing up in over 6 months! After installing and using Ubuntu, I couldn't really see a need for Windows anymore. ;) Plus, as mentioned earlier I'd be perfectly willing to take a look at the source code and see if I can figure out what lines need changed and compile it myself so that it could work on Ubuntu as well. So don't worry, I'm definitely NOT disappointed.

The way I see it, I switched from using Windows from version 3.1 all the way up to WinXP over to using Ubuntu exclusively within a years time of discovering & trying Ubuntu & have never looked back. Which means I had to learn A LOT in order to do stuff in Ubuntu that I was used to doing on Windows and for me it's been a great LEARNING experience which continues everyday. At one time, I was a bit intimidated by the command line whereas now, I prefer using the Terminal (command line) for many tasks that in Windows I would have used a GUI application of some sort.

So I'm kind of looking forward to seeing your source code and making it work on Ubuntu (even w/o really knowing C++). I'm definitely NOT afraid to learn new things & this could be an awesome learning experience for me! So I'm still looking forward to testing it out. Perhaps once you get this working for yourself you could send me a sample SVG and maybe screenshots of what is supposed to happen so I can more fully understand it?

Anyway, good luck and I look forward to seeing what you come up with!

User avatar
Lucas?
Posts: 13
Joined: Wed Jun 26, 2013 10:46 am

Re: Export selected groups as PNG's

Postby Lucas? » Mon Jul 01, 2013 6:52 pm

Thanks again BetaTestingPro. Enjoyed a lot reading through your post ;)
BetaTestingPro wrote:Hmmmm? Well, I tried to give advice that I thought would work. Sorry it did not work out for you. I only hope it didn't waste too much of your time.
Man, for that I should be the one apologizing. I hope you've not lost so much time trying to help me out.
BetaTestingPro wrote:Well, that sounds great and though I'm NOT a C++ programmer myself, I'm certainly not against looking at your source code and trying to compile it myself for Ubuntu. And even if I can't do it, I may know someone who can.

That's great! Hope the source code can actually be of some use :P though I'm not worried about it anyway :)

BetaTestingPro wrote:Perhaps once you get this working for yourself you could send me a sample SVG and maybe screenshots of what is supposed to happen so I can more fully understand it?

Sure ;) I can actually post it publicly so everyone can get an idea of what it's supposed to do.

Update:
Ok, guess what again? I discovered Inkscape supports extensions written on any language! Not just Python :P This is amazing! So, I've got delayed a little with the program because now I'm making it to behave as an extension which can be called directly from Inkscape. This is way cooler isn't it?

But also, I just want to ask one more simple question:
As you may know by now, I'm piping batch commands to Inkscape. The problem is whenever I write a filename with a folder's path Inkscape can't recognize it! It's apparently because of the white spaces contained on the path's name. What am I supposed to do in order to make Inkscape recognize those paths?

Edit:
Never mind, just need to put the path+filename inside double-quotes (").

BetaTestingPro
Posts: 38
Joined: Mon Aug 15, 2011 3:27 am

Re: Export selected groups as PNG's

Postby BetaTestingPro » Mon Jul 01, 2013 10:01 pm

Lucas? wrote:Thanks again BetaTestingPro. Enjoyed a lot reading through your post ;)


That's great to hear! At least I know I'm NOT wasting my time. :)

Lucas? wrote:Man, for that I should be the one apologizing. I hope you've not lost so much time trying to help me out.


Nope, not at all. I enjoy trying to help when I can. And I still managed to finish up a Tutorial and FINALLY posted here on the forum. It's nothing special for people that already know how to use Inkscape really. But I've been hanging on to it for quite some time and finally got it posted. Hopefully, someone will find it useful or at least offer some feedback of some sort. :|

BetaTestingPro wrote:Well, that sounds great and though I'm NOT a C++ programmer myself, I'm certainly not against looking at your source code and trying to compile it myself for Ubuntu. And even if I can't do it, I may know someone who can.


Lucas? wrote:That's great! Hope the source code can actually be of some use :P though I'm not worried about it anyway :)


BetaTestingPro wrote:Perhaps once you get this working for yourself you could send me a sample SVG and maybe screenshots of what is supposed to happen so I can more fully understand it?


Lucas? wrote:Sure ;) I can actually post it publicly so everyone can get an idea of what it's supposed to do.


Awesome! I'm looking forward to seeing what you do.

Lucas? wrote:Update:
Ok, guess what again? I discovered Inkscape supports extensions written on any language! Not just Python :P This is amazing! So, I've got delayed a little with the program because now I'm making it to behave as an extension which can be called directly from Inkscape. This is way cooler isn't it?


Oh, Really? I wasn't aware of that. That is freaking awesome! I've personally only edited existing extensions to add functionality after taking an extension tutorial a year or so ago. The extensions I worked on were always Python and I thought that was what all Inkscape extensions were written in. Well, sounds like you are moving right along and learning cool things about Inkscape. I'm still looking forward to seeing what you come up with.

Lucas? wrote:But also, I just want to ask one more simple question:
As you may know by now, I'm piping batch commands to Inkscape. The problem is whenever I write a filename with a folder's path Inkscape can't recognize it! It's apparently because of the white spaces contained on the path's name. What am I supposed to do in order to make Inkscape recognize those paths?

Edit:
Never mind, just need to put the path+filename inside double-quotes (").


:lol: Isn't it great when you are able to answer your own question? You gotta love it.


Return to “Help with using Inkscape”