RSS/Atom feed Twitter
Site is read-only, email is disabled

Programmatically modifying text in .xcf files.

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

9 of 9 messages available
Toggle history

Please log in to manage your subscriptions.

Programmatically modifying text in .xcf files. mal content 26 Jul 20:11
  Programmatically modifying text in .xcf files. John R. Culleton 26 Jul 20:39
   Programmatically modifying text in .xcf files. mal content 26 Jul 21:18
    Programmatically modifying text in .xcf files. John R. Culleton 26 Jul 21:25
     Programmatically modifying text in .xcf files. mal content 26 Jul 22:03
      Programmatically modifying text in .xcf files. Bruce Bertrand 26 Jul 22:49
      Programmatically modifying text in .xcf files. John R. Culleton 26 Jul 23:36
   Programmatically modifying text in .xcf files. Simon Budig 27 Jul 00:20
  Programmatically modifying text in .xcf files. Sven Neumann 26 Jul 23:03
mal content
2007-07-26 20:11:32 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

Hello.

I have a large number of xcf files that have a section of text embedded in them. Is there a tool or method available to safely and reliably modify this text (replace it with other text) from the shell, or some other interface that doesn't require me to open 100 or so files in Gimp*?

I'd ideally like to be able to do something along the lines of:

$ for f in *.xcf; do xcf_text_replace $layer_num file.txt; done

thanks, MC

* they are huge files, I doubt my hardware could cope.

John R. Culleton
2007-07-26 20:39:07 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

On Thursday 26 July 2007, mal content wrote:

Hello.

I have a large number of xcf files that have a section of text embedded in them. Is there a tool or method available to safely and reliably modify this text (replace it with other text) from the shell, or some other interface that doesn't require me to open 100 or so files in Gimp*?

I'd ideally like to be able to do something along the lines of:

$ for f in *.xcf; do xcf_text_replace $layer_num file.txt; done

thanks, MC

* they are huge files, I doubt my hardware could cope. _______________________________________________ Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

_________________________________________________________________ Need personalized email and website? Look no further. It's easy with Doteasy $0 Web Hosting! Learn more at www.doteasy.com

If you are on a Linux or similar platform something along the lines of awk or sed could be possible approaches. I quote from an old manual:
"The advantages of sed are that it can apply the same editing comands to many files; it can edit a large file quickly; and it can readily be used with pipes."

mal content
2007-07-26 21:18:05 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

On 26/07/07, John R. Culleton wrote:

If you are on a Linux or similar platform something along the lines of awk or sed could be possible approaches. I quote from an old manual:
"The advantages of sed are that it can apply the same editing comands to many files; it can edit a large file quickly; and it can readily be used with pipes."

Yes, the thing I was worried about though is damaging the binary files. The text I wish to replace the original text with is about twice the length of the original. Is the xcf file format flexible enough to really allow editing in this way?

thanks,
MC

John R. Culleton
2007-07-26 21:25:45 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

On Thursday 26 July 2007, mal content wrote:

On 26/07/07, John R. Culleton wrote:

If you are on a Linux or similar platform something along the lines of awk or sed could be possible approaches. I quote from an old manual:
"The advantages of sed are that it can apply the same editing comands to many files; it can edit a large file quickly; and it can readily be used with pipes."

Yes, the thing I was worried about though is damaging the binary files. The text I wish to replace the original text with is about twice the length of the original. Is the xcf file format flexible enough to really allow editing in this way?

thanks,
MC

Don't know :

mal content
2007-07-26 22:03:43 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

On 26/07/07, John R. Culleton wrote:

Don't know :

Well what it basically is, is a CD cover and booklet. The cover and booklet conform to an image template so that they print the correct size and with correct margins at a given DPI.

The covers are being produced for a range of CDs (the layout is the same on each disks but the images are different). The first page of every booklet lists credits and other information and these now have to be changed en masse as the text has been rewritten.

I suppose I could export the covers to a page layout program but that would take a lot of work and would complicate our release process quite a bit.

I'm not averse to the idea of writing a program to make these transformations in C, but I'm not aware of the existence of a 'libxcf' or equivalent to access the file format and I really don't want to have to do my own parsing!

cheers,
MC

Bruce Bertrand
2007-07-26 22:49:43 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

On Thu, 2007-07-26 at 21:03 +0100, mal content wrote:

On 26/07/07, John R. Culleton wrote:

Don't know :

Well what it basically is, is a CD cover and booklet. The cover and booklet conform to an image template so that they print the correct size and with correct margins at a given DPI.

The covers are being produced for a range of CDs (the layout is the same on each disks but the images are different). The first page of every booklet lists credits and other information and these now have to be changed en masse as the text has been rewritten.

I suppose I could export the covers to a page layout program but that would take a lot of work and would complicate our release process quite a bit.

I'm not averse to the idea of writing a program to make these transformations in C, but I'm not aware of the existence of a 'libxcf' or equivalent to access the file format and I really don't want to have to do my own parsing!

cheers,
MC

You should check out Swiss File Knife. It's a sed-like program that works on binaries as well as text. Just be sure to back up your original data.

http://sourceforge.net/projects/swissfileknife

~B

Sven Neumann
2007-07-26 23:03:15 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

Hi,

On Thu, 2007-07-26 at 19:11 +0100, mal content wrote:

I have a large number of xcf files that have a section of text embedded in them. Is there a tool or method available to safely and reliably modify this text (replace it with other text) from the shell, or some other interface that doesn't require me to open 100 or so files in Gimp*?

We are still lacking a proper PDB API for text layer and without this you can't do what you are asking for. Hopefully someone will contribute this missing part at some point.

Sven

John R. Culleton
2007-07-26 23:36:20 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

On Thursday 26 July 2007, mal content wrote:

On 26/07/07, John R. Culleton wrote:

Don't know :

Well what it basically is, is a CD cover and booklet. The cover and booklet conform to an image template so that they print the correct size and with correct margins at a given DPI.

I suggest that the cover art is a good Gimp application but the booklets aren't. An application such as TeX (e.g, Context) could prepare those pages. If art work or backgrounds etc. were needed they could be prepared via Gimp or a drawing program and incorporated as needed on the pages. But gimp would not be used to create the final image to go to the printer. That way you would have the flexibiilty to substitute text in a batch editor program like sed and have the pages adjust automatically. Margins are easily controlled in a layout program and dpi is not really a factor with text.

I am afraid that you may have painted yourself into a corner by using gimp as a page layout program. That is not its strength. If you send me a sample of one of the bookets I will see what I can do with a conversion program.

Simon Budig
2007-07-27 00:20:02 UTC (over 17 years ago)

Programmatically modifying text in .xcf files.

John R. Culleton (john@wexfordpress.com) wrote:

On Thursday 26 July 2007, mal content wrote:

Is there a tool or method available to safely and reliably modify this text (replace it with other text) from the shell, or some other interface that doesn't require me to open 100 or so files in Gimp*?

If you are on a Linux or similar platform something along the lines of awk or sed could be possible approaches.

You would end up with invalid xcf files. Even if you could replace the text without damaging the file structure your image still would look the same, since even text layers are stored as pixels. The text you find in the xcf file is metainformation that would get used if you'd change the text in the gimp and thus would force gimp to re-render the text layer.

So basically the only tool being able to effectively change the text is the Gimp itself. And - as Sven mentioned - since we unfortunately do not have a PDB API for this functionality it is impossible to create a script to let gimp do this.

Bye, Simon