Gimptalk - Premier Gimp Community: Images open as modified when using python.. - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Images open as modified when using python..

#1 User is offline   ragtag 

  • Member
  • PipPip
  • Group: Members
  • Posts: 75
  • Joined: 28-December 08

Posted 20 November 2011 - 08:56 PM

I'm working on a script that loads images from a pygtk window in gimp.

When running this little snippet of code:

pagepath = '/path/to/my/image.xcf'
img = pdb.gimp_file_load(pagepath, pagepath)
gimp.Display(img)


The images load up in GIMP just fine, but the "modified" flag has been set. There is an '*' next to the file name in the title bar, and if you try to close the image, GIMP asks if you want to save the changes. Though there are no visible changes to the image.

What am I doing wrong?
Posted Image
Depending on where you work, site may be not safe for work. :)
0

#2 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,905
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 20 November 2011 - 09:12 PM

View Postragtag, on 20 November 2011 - 08:56 PM, said:

I'm working on a script that loads images from a pygtk window in gimp.

When running this little snippet of code:

pagepath = '/path/to/my/image.xcf'
img = pdb.gimp_file_load(pagepath, pagepath)
gimp.Display(img)


The images load up in GIMP just fine, but the "modified" flag has been set. There is an '*' next to the file name in the title bar, and if you try to close the image, GIMP asks if you want to save the changes. Though there are no visible changes to the image.

What am I doing wrong?
I get the same result. image.dirty is True, so that's coherent. Unfortunately, image.dirty cannot be written. Good question to ask to the gimp-developer mailing list.
010011110110011001101110011101010111010001110011
0

#3 User is offline   paynekj 

  • Member
  • PipPip
  • Group: Members
  • Posts: 383
  • Joined: 01-June 05
  • LocationUK

Posted 21 November 2011 - 09:58 AM

There is a PDB function to clear the dirty flag: gimp-image-clean-all
Kevin
0

#4 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,905
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 21 November 2011 - 01:43 PM

View Postpaynekj, on 21 November 2011 - 09:58 AM, said:

There is a PDB function to clear the dirty flag: gimp-image-clean-all
Good find. In Python one can even use image.clean_all() to the same effect.
010011110110011001101110011101010111010001110011
0

#5 User is offline   paynekj 

  • Member
  • PipPip
  • Group: Members
  • Posts: 383
  • Joined: 01-June 05
  • LocationUK

Posted 21 November 2011 - 04:50 PM

I still think it's worth asking the question of the developers, as opening a new image and marking it dirty is odd behaviour.
Kevin
0

#6 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,905
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 21 November 2011 - 08:53 PM

View Postpaynekj, on 21 November 2011 - 04:50 PM, said:

I still think it's worth asking the question of the developers, as opening a new image and marking it dirty is odd behaviour.
Question asked...
010011110110011001101110011101010111010001110011
0

#7 User is offline   ragtag 

  • Member
  • PipPip
  • Group: Members
  • Posts: 75
  • Joined: 28-December 08

Posted 22 November 2011 - 12:41 AM

Thanks for the reply. image.clean_all() works perfectly.

The plug-in I'm working on is an interface for managing multiple pages of a book (adding, removing, reordering and exporting pages) mainly meant for comics work. I'll be sure to post it here when it's done.

ofnuts: Let us know if you get a reply on the mailing list. :)
Posted Image
Depending on where you work, site may be not safe for work. :)
0

#8 User is offline   paynekj 

  • Member
  • PipPip
  • Group: Members
  • Posts: 383
  • Joined: 01-June 05
  • LocationUK

Posted 22 November 2011 - 08:59 AM

Out of curiosity I did the same thing in script-fu:
    	(set! image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))   	
    	(gimp-display-new image)
    	(gimp-displays-flush)

And it does the same thing - it sets the dirty flag.

Reading the Additional information in the procedure browser for gimp-image-clean-all gives a clue:
This procedure sets the specified image's dirty count to
 0, allowing operations to occur without having a 'dirtied'
 image. This is especially useful for creating and loading
 images which should not initially be considered dirty,
 even though layers must be created, filled, and installed
 in the image. Note that save plug-ins must NOT call this
 function themselves after saving the image.


So, although you are only loading an image, GIMP is having to create layer(s) and fill them with the image - which it obviously counts as having modified the image.

This post has been edited by paynekj: 22 November 2011 - 09:00 AM

Kevin
0

#9 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,905
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 22 November 2011 - 09:12 AM

View Postpaynekj, on 22 November 2011 - 08:59 AM, said:

Out of curiosity I did the same thing in script-fu:
    	(set! image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))   	
    	(gimp-display-new image)
    	(gimp-displays-flush)

And it does the same thing - it sets the dirty flag.

Reading the Additional information in the procedure browser for gimp-image-clean-all gives a clue:
This procedure sets the specified image's dirty count to
 0, allowing operations to occur without having a 'dirtied'
 image. This is especially useful for creating and loading
 images which should not initially be considered dirty,
 even though layers must be created, filled, and installed
 in the image. Note that save plug-ins must NOT call this
 function themselves after saving the image.


So, although you are only loading an image, GIMP is having to create layer(s) and fill them with the image - which it obviously counts as having modified the image.
I've seen that too, but the logic is a bit dubious... "File/Open" doesn't set the dirty flag, and I don't see any functional difference with gimp-file-load-(). And neither does File/New, btw....
010011110110011001101110011101010111010001110011
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic