Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
current folder in plugin
#3
(02-28-2024, 11:08 PM)Ofnuts Wrote: If you mean the folder form the image, then:
  • Given timg
  • timg.filename is the complete path to the file the image was loaded from
  • os.path.dirname(some_path) extracts the parent directory in a path
  • so what you want is in  os.path.dirname(timg.filename)
So you code looks like:

Code:
import os  # somewhere at the top of your file, otherwise os.path.dirname won't be resolved

pdb.python_fu_ofn_export_layers(timg, os.path.dirname(timg.filename)), "{numUp0}.png", "-", 0)

I have a working small plugin.
At the top is this

Code:
from gimpfu import*



When adding

Code:
import os

above or below this line and adding the line you gave me, the plugin does not appear anymore in GIMP.

If I remove the line, it appears again Rolleyes
Reply


Messages In This Thread
current folder in plugin - by gimpygirl - 02-28-2024, 06:46 PM
RE: current folder in plugin - by Ofnuts - 02-28-2024, 11:08 PM
RE: current folder in plugin - by gimpygirl - 02-29-2024, 12:22 AM
RE: current folder in plugin - by Ofnuts - 02-29-2024, 12:48 AM
RE: current folder in plugin - by gimpygirl - 02-29-2024, 01:12 AM
RE: current folder in plugin - by Ofnuts - 02-29-2024, 12:07 PM
RE: current folder in plugin - by gimpygirl - 02-29-2024, 06:33 PM
RE: current folder in plugin - by Ofnuts - 02-29-2024, 11:34 PM
RE: current folder in plugin - by gimpygirl - 03-01-2024, 12:28 AM
RE: current folder in plugin - by Ofnuts - 03-01-2024, 07:35 AM
RE: current folder in plugin - by gimpygirl - 03-01-2024, 08:43 PM
RE: current folder in plugin - by Ofnuts - 03-01-2024, 09:32 PM
RE: current folder in plugin - by gimpygirl - 03-03-2024, 01:49 AM
RE: current folder in plugin - by Ofnuts - 03-03-2024, 04:39 PM
RE: current folder in plugin - by gimpygirl - 03-04-2024, 02:14 AM

Forum Jump: