This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 38 - Pages: 3 [ Previous | 1 2 3 ] - Last Post: 26 Nov 17, 00:29 Last Post By: JeffTucker
davidekholm

Posts: 4,130
Registered: 18-Oct-2002
Re: Theme Images: option to suppress them for subfolders
Posted: 25 Nov 17, 19:06   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:

That's pretty much what I'm already doing, but that generates a theme image for every folder. I don't see how that can be altered to produce a theme image only at the root level.

If you only want a theme image in the root level, just put that code inside init and refer to rootFolder and rootOutputDirectory instead of currentFolder and outputDirectory.
JeffTucker

Posts: 8,142
Registered: 31-Jan-2006
Re: Theme Images: option to suppress them for subfolders
Posted: 25 Nov 17, 19:16   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
If you only want a theme image in the root level, just put that code inside init and refer to rootFolder and rootOutputDirectory instead of currentFolder and outputDirectory.

That code doesn't refer to currentFolder or outputDirectory. Here's what I've got in init.bsh:
ThemeImageProcessor custom = new ThemeImageProcessor() {
	public String getThemePath(AlbumObject folder) {
		return "sa_theme.jpg";
	}
};
if(useThemes) {
	engine.setThemeImageProcessor(custom);
}
This renames the output file and plants it at the root level of each folder directory.

Sorry if I'm being obtuse (I'm in the middle of a bunch of other stuff at the moment, and not paying enough attention to this), but I just don't see how to alter that to produce only a single theme image.
RobM

Posts: 4,179
Registered: 4-Aug-2006
Re: Theme Images: option to suppress them for subfolders
Posted: 25 Nov 17, 19:23   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
davidekholm wrote:
If you only want a theme image in the root level, just put that code inside init and refer to rootFolder and rootOutputDirectory instead of currentFolder and outputDirectory.

That code doesn't refer to currentFolder or outputDirectory. Here's what I've got in init.bsh:

ThemeImageProcessor custom = new ThemeImageProcessor() {
	public String getThemePath(AlbumObject folder) {
		return "sa_theme.jpg";
	}
};
if(useThemes) {
	engine.setThemeImageProcessor(custom);
}
This renames the output file and plants it at the root level of each folder directory.

Sorry if I'm being obtuse (I'm in the middle of a bunch of other stuff at the moment, and not paying enough attention to this), but I just don't see how to alter that to produce only a single theme image.

See method two in the wiki hel page :)
JeffTucker

Posts: 8,142
Registered: 31-Jan-2006
Re: Theme Images: option to suppress them for subfolders
Posted: 25 Nov 17, 19:29   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
See method two in the wiki hel page :)

I'm sure that works, but ugh. Easier to do a little recursive script in finally.bsh that deletes the theme image everywhere except the top level. It would probably run in less than one second, and would be about 5 lines long.

Edit: In postdir.bsh, you wouldn't even need recursion. Assuming the theme image is at the root of the folder (rather than in slides):
if(level > 0) {
	File f = new File(outputDirectory + "/sa_theme.jpg");
	try {
		f.delete();
	}
	catch(IOException e) {}
}
AndreWolff

Posts: 2,213
Registered: 14-Dec-2007
Re: Theme Images: option to suppress them for subfolders
Posted: 25 Nov 17, 19:43   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Well David in one of my first implementations I did put the statement
engine.setThemeImageProcessor(new ThemeImageProcessor());
in index.htt, but in that case the variables themePath, themeWidth and themeHeight did not get a value. I never understood that.
I did that to get in index.htt the possibility to generate or not generate a theme image.

Now I have that line of code in init.bsh, so it is executed only once for an album with a lot of folders. I still don’t understand when and what triggers the theme generation.

I agree with jGromit that it should be possible to call in index.htt a function which could suppress the generation of a theme image.

Edited by: AndreWolff on 25-Nov-2017 20:19
davidekholm

Posts: 4,130
Registered: 18-Oct-2002
Re: Theme Images: option to suppress them for subfolders
Posted: 25 Nov 17, 21:49   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
davidekholm wrote:
If you only want a theme image in the root level, just put that code inside init and refer to rootFolder and rootOutputDirectory instead of currentFolder and outputDirectory.

That code doesn't refer to currentFolder or outputDirectory. Here's what I've got in init.bsh:

ThemeImageProcessor custom = new ThemeImageProcessor() {
	public String getThemePath(AlbumObject folder) {
		return "sa_theme.jpg";
	}
};

Ah, that's the minimal code you need to use to get the general behavior. If you want to customize it, you can either subclass the ThemeImageProcessor and alter its behavior or use the script referred to as "Method 2" here: http://jalbum.net/help/en/Sample_scripts#Theme_images

Now "Method 2" seems rather lengthy (although being most flexible) so I'd prefer subclassing: Here's how it could look (in init)
       ThemeImageProcessor custom = new ThemeImageProcessor() {
            @Override
            public String getThemePath(AlbumObject folder) {
                return "sa_theme.jpg";
            }
 
            @Override
            public void processThemeImage(AlbumObject folder, File outputDir) throws IOException {
                if (folder == rootFolder) {
                    super.processThemeImage(folder, outputDir); //To change body of generated methods, choose Tools | Templates.                    
                }
            }
        };
        engine.setThemeImageProcessor(custom);
 
JeffTucker

Posts: 8,142
Registered: 31-Jan-2006
Re: Theme Images: option to suppress them for subfolders
Posted: 25 Nov 17, 22:08   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Have you actually tried this? I'm guessing not... ;)

Edit: I won't keep you in suspense. There's no @Override in Beanshell, apparently. The error message is actually, "Encountered O after @," or something to that effect.

Just killing those two lines, it seems to work.
davidekholm

Posts: 4,130
Registered: 18-Oct-2002
Re: Theme Images: option to suppress them for subfolders
Posted: 26 Nov 17, 00:10   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
Have you actually tried this? I'm guessing not... ;)

Edit: I won't keep you in suspense. There's no @Override in Beanshell, apparently. The error message is actually, "Encountered O after @," or something to that effect.

Just killing those two lines, it seems to work.


I simply "tested" the code in NetBeans (using its on-the-fly code verification, assuming you had compiled code too. Yes, as you figured out one has to dump the @Override annotations to make it work in BeanShell. Oh God I wish they updated BeanShell.
JeffTucker

Posts: 8,142
Registered: 31-Jan-2006
Re: Theme Images: option to suppress them for subfolders
Posted: 26 Nov 17, 00:29   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Well, at least my guessing percentage keeps getting better. :)
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums