It is currently Thu Apr 18, 2024 5:15 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: deleting a newly created pattern
PostPosted: Tue Jul 07, 2015 12:16 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: Basic Level



Hi
assuming a script has created a new pattern (file-pat-save), which is the correct way (if there is any) to delete it at the end?
I didn't find a file-pat-delete nor a gimp-pattern-delete and the gimp-item-delete seems not to accept a pattern name as item
thanks

_________________
"Where am I ?"


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: deleting a newly created pattern
PostPosted: Tue Jul 07, 2015 2:08 am  (#2) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 13005
Location: Native to NYC living in Arizona, Gimp 2.8 & 2.10, Win 11 PC.
Try this...
Image

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: deleting a newly created pattern
PostPosted: Tue Jul 07, 2015 4:26 am  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4735
Why do you create a pattern file? You can do a clipboard copy of the pattern image, and then use the clipboard pattern (always the first in the list of patterns)(*).

Otherwise, no specific API to erase patterns on the disk from a script, you have to do this with standard filesystem calls (if you can tell the filename...).

(*) In the general case, scripts should avoid copying things to the clipboard and/or using them, because the clipboard is a system-wide resource and you can't control what happens to it between your copy and your paste. And you don't know if the script isn't going to overwrite something the user (who could be using another app while the script runs) has just copied.

_________________
Image


Top
 Post subject: Re: deleting a newly created pattern
PostPosted: Tue Jul 07, 2015 5:34 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
@Wallace: thanks, but I wanted to ask a way to perform the deletion from inside the script

@Ofnuts: thanks, and -as you said in the note (*) - I prefer to file-save my temporary pattern. Thus I need to delete it manually, outside the script (so, you come back on the play, Wallace!)

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a newly created pattern
PostPosted: Tue Jul 07, 2015 6:46 am  (#5) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4735
dinasset wrote:
GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: Basic Level



Hi
assuming a script has created a new pattern (file-pat-save), which is the correct way (if there is any) to delete it at the end?
I didn't find a file-pat-delete nor a gimp-pattern-delete and the gimp-item-delete seems not to accept a pattern name as item
thanks

If you do a file-pat-save, then you supply a complete file name, so getting rid of the pattern file later is just a matter of using that same file name with some 'erase'/'unlink' function, if script-fu has such (otherwise, as always, you can upgrade to a real programming language that will have one).

_________________
Image


Top
 Post subject: Re: deleting a newly created pattern
PostPosted: Tue Jul 07, 2015 7:22 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Ofnuts
my script is written in Python (yes, I'm a little bit re-studying Python), so, in this case, which one is the gimp_python function to use? thanks

edit: the Python function used to create it is the following:
        pdb.file_pat_save(inImage, Layer_two,
                          gimp.directory+"/patterns/temppat/temp.pat",
                          gimp.directory+"/patterns/temppat/temp.pat", "temporary_pat")

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a newly created pattern
PostPosted: Tue Jul 07, 2015 7:42 am  (#7) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4735
Not gimp-python...
import os

os.remove(gimp.directory+'/patterns/temppat/temp.pat')

_________________
Image


Last edited by ofnuts on Tue Jul 07, 2015 8:27 am, edited 1 time in total.

Top
 Post subject: Re: deleting a newly created pattern
PostPosted: Tue Jul 07, 2015 7:50 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
excellent! added your suggested two instructions, and the deletion works perfectly!
Thanks a lot, Ofnuts!

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Newly Added Brush Demos by SenlinOS

2

No new posts Deleting GIMP

2

No new posts Attachment(s) Colorful Pattern from Text (Text Pattern) Plug-in

32

No new posts Attachment(s) Geometric patterns I created

0

No new posts delete a created template

3



* Login  



Powered by phpBB3 © phpBB Group