Copying an .xcf file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Copying an .xcf file

Developers mailing list
Hello GIMP Developers,

My name is Nonso Iwu and I have been using GIMP to create portraits as an
online service.

Since I have to create multiple files for new portraits, I decided to
automate this process by adding a shell command to my machine using C. I
try to read the template .xcf file as a normal file (using fopen()) and
write the contents of that file into a new .xcf file (using fputc()). I
wait for an EOF character in order to indicate when to stop reading from
the file.

Essentially, I am trying to copy a template .xcf file and rename it.
However, whenever I perform these actions, the file is not copied
completely (an 500KB template producing a 1KB clone seems incorrect).

So my questions are:
Am I reading these .xcf files correctly?
Is there another way of reading these files?
Is there a library of functions for reading an .xcf?

Thank you all for your work on this open source project!

Awaiting your response,
Nonso Iwu

--
*ZoVirtuoso*
Nonso Iwu
Instagram: @zovirtuoso

*Tell your friends to request a portrait!*
_______________________________________________
gimp-developer-list mailing list
List address:    [hidden email]
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list
Reply | Threaded
Open this post in threaded view
|

Re: Copying an .xcf file

Liam R E Quin
On Sun, 2019-11-10 at 14:51 -0500, ZoVirtuoso via gimp-developer-list
wrote:
> Since I have to create multiple files for new portraits, I decided to
> automate this process by adding a shell command to my machine using
> C.

It's much better top use a scripting language for something like this.

> I
> wait for an EOF character in order to indicate when to stop reading
> from the file.
There's no such thing as an EOF character in C; instead, getc() will
return -1; note that this does not fit into an unsigned char, so getc
returns an int.

> Essentially, I am trying to copy a template .xcf file and rename it.
On a Unix/Linux system, the shell command,
  cp "$template" `basename "$template" .xcf`-2.xcf
will rename $template. One line, no getc or EOF.

Or you could write a GIMP plugin in Python.

slave ankh


_______________________________________________
gimp-developer-list mailing list
List address:    [hidden email]
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list
Reply | Threaded
Open this post in threaded view
|

Re: Copying an .xcf file

Developers mailing list
Thanks for the feedback, Liam!

That’s the general gist of what I ended up doing. The C program just runs a
batch script in the parent directory.

Thanks again for the insight,
-Nonso Iwu

On Fri, Nov 15, 2019 at 4:02 PM Liam R E Quin <[hidden email]> wrote:

> On Sun, 2019-11-10 at 14:51 -0500, ZoVirtuoso via gimp-developer-list
> wrote:
> > Since I have to create multiple files for new portraits, I decided to
> > automate this process by adding a shell command to my machine using
> > C.
>
> It's much better top use a scripting language for something like this.
>
> > I
> > wait for an EOF character in order to indicate when to stop reading
> > from the file.
> There's no such thing as an EOF character in C; instead, getc() will
> return -1; note that this does not fit into an unsigned char, so getc
> returns an int.
>
> > Essentially, I am trying to copy a template .xcf file and rename it.
> On a Unix/Linux system, the shell command,
>   cp "$template" `basename "$template" .xcf`-2.xcf
> will rename $template. One line, no getc or EOF.
>
> Or you could write a GIMP plugin in Python.
>
> slave ankh
>
>
> --
*ZoVirtuoso*
Nonso Iwu
Instagram: @zovirtuoso

*Tell your friends to request a portrait!*
_______________________________________________
gimp-developer-list mailing list
List address:    [hidden email]
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list