Posts:
2,642
Registered:
6-Sep-2005
|
|
|
Re: Getting the slide image for a folder
Posted:
23-Mar-2018 08:35
in response to: RobM
|
|
|
"lastFolderImagePath" is a Turtle- (Tiger, Photoblogger) specific variable that stores the previous folder image path in order to avoid unnecessary regeneration. This is why it's not documented.
|
|
|
Posts:
7,103
Registered:
31-Jan-2006
|
|
|
Re: Getting the slide image for a folder
Posted:
23-Mar-2018 11:43
in response to: JeffTucker
|
|
|
Using imagePath turns out to be a non-starter, even if the "scaled vs. original" bug were fixed. A user can choose an image as the folder thumbnail, but then exclude it. In that case, there's no full-sized image in the output, either scaled or original, for the skin to point to. There's only a thumbnail, which won't do for this application.
More rethinking needed....
|
|
|
Posts:
7,103
Registered:
31-Jan-2006
|
|
|
Re: Getting the slide image for a folder
Posted:
25-Mar-2018 05:54
in response to: JeffTucker
|
|
|
Problem solved by taking a different tack, using the regular "use as folder thumbnail" indicator.
- First, check for iconPath - if it's not null, don't do anything. That means that no image has been chosen to represent the folder, and I don't want to show folder.png as a page background.
- Otherwise, pick up the representingFile.
- If the user has chosen Link to originals, copy the representingFile to the output (with a standard name, like folderimage.jpg), and use it as the page background.
- For any other linking choice, scale the representingFile to the image bounds, and write it to the output (again, folderimage.jpg), and use it as the page background.
Only one mystery still to be solved. If the user crops the image using the jAlbum image editing tools, that cropping is applied to the generated slide image. But I don't know how to grab that information and apply it when the skin is doing its own scaling.
Any help on that one?
|
|
|
Posts:
572
Registered:
27-Sep-2003
|
|
|
Re: Getting the slide image for a folder
Posted:
25-Mar-2018 20:12
in response to: JeffTucker
|
|
|
|
If the user crops the image using the jAlbum image editing tools, that cropping is applied to the generated slide image. But I don't know how to grab that information and apply it when the skin is doing its own scaling.
Mirage sometimes generates scaled filtered images. This method is attached. It applies all filters, not just cropping. This probably handles some scenarios that you don't need; you can probably work out what can be discarded.
BTW I left the processing of the Play icon in here just to annoy you!
Edited by: ctwist on 25-Mar-2018 16:19
Added "scaled".
|
|
|
Posts:
7,103
Registered:
31-Jan-2006
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 03:21
in response to: ctwist
|
|
|
I guess I'm missing something, but I don't see how that code is picking up the image editing parameters from the .info file associated with the image.
|
|
|
Posts:
572
Registered:
27-Sep-2003
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 16:21
in response to: JeffTucker
|
|
|
To see this in action, create a Mirage album containing mydog.jpg and mydog_1_.jpg. Crop mydog_1_.jpg. This generates a single slide page containing 2 thumbnails (the second thumbnail is cropped). Click on this thumbnail to see the cropped full-size image. The code that I provided generates the two cropped images.
I haven't looked at this code for a long time. I think that vAlbumImage = vAlbumImage.applyFilters(JAFilter.ALL_PRESCALE_STAGE)code fragment;
applies the cropping filter.
Edited by: ctwist on 26-Mar-2018 11:19
Correction: cropping must be done by ALL_PRESCALE_STAGE
|
|
|
Posts:
7,103
Registered:
31-Jan-2006
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 17:14
in response to: ctwist
|
|
|
Interesting. Using applyFilters(JAFilter.ALL_PRESCALE_STAGE), since I want the filtering for both thumbnails and slides, it seems to be applying some, but not all, of the image editing. It seems to be picking up cropping and straightening, but not flipping, gamma, or brightness/contrast. Better than nothing, to be sure, but oddly selective.
But in Mirage, it does pick up all the image editing (though I need to force a Make All to trigger it). So, what's needed is in there somewhere - I just need to do some tinkering to hunt it down.
Edit: Ah, I think I see. If the scaled image already exists, Mirage is using that as the starting point. But if image editing tools have been used on that image, the scaled image already contains all of the results - cropping, gamma, contrast, etc., etc. In short, the Mirage code isn't actually producing this.
Edited by: jGromit on 26-Mar-2018 11:16
|
|
|
Posts:
572
Registered:
27-Sep-2003
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 17:22
in response to: JeffTucker
|
|
|
In short, the Mirage code isn't actually producing this.
Actually it is. This method is called twice; first for the main image and then for the thumbnail.
|
|
|
Posts:
7,103
Registered:
31-Jan-2006
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 17:35
in response to: ctwist
|
|
|
I just can't follow the code - there are too many variables whose meaning is unclear to me. All I know is that if I do this in predir.bsh, only the cropping and straightening image edits are applied: if(useFolderimage) {
File repFile = new File(currentFolder.getVars().get("representingFile").toString());
File folderImage = new File(outputDirectory, "folderimage.jpg");
if(engine.getImageLinking().equals(AlbumBean.LINK_ORIGINALS) || currentFolder.getRepresentingAlbumObject().isUseOriginal()) IO.copyFile(repFile, folderImage);
else {
AlbumImage ai = new AlbumImage(repFile, engine);
ai = ai.applyFilters(JAFilter.ALL_PRESCALE_STAGE);
ai = ai.scaleToFit(new Dimension(maxImageWidth, maxImageHeight));
ai.saveImage(folderImage, engine.getQualityPercent());
}
}
|
|
|
Posts:
572
Registered:
27-Sep-2003
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 20:09
in response to: JeffTucker
|
|
|
I can fix your code, but first a question: do you need a thumbnail or just a full-size image?
|
|
|
Posts:
7,103
Registered:
31-Jan-2006
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 20:34
in response to: ctwist
|
|
|
Don't expend a lot of effort on this - I've adopted a different approach (again).
But if I return to this, I would need a slide image that uses whatever image editing the user has applied to this image - cropping, flipping, gamma, whatever. In short, I want to get the same image that the jAlbum engine would create in the slides directory on its own.
|
|
|
Posts:
572
Registered:
27-Sep-2003
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 21:27
in response to: JeffTucker
|
|
|
|
An updated code sample is attached.
- My previous code sample was incomplete. The attached file contains the missing methods.
- I have removed the code that you don't need.
- I added some includes. Yoiu probably don't need all of these.
- I don't know what background color is needed for transparent images. You need to provide this.
|
|
|
Posts:
7,103
Registered:
31-Jan-2006
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 22:18
in response to: ctwist
|
|
|
Talk about the long way 'round Robin Hood's barn!
Turns out that it just took one little tweak: if(useFolderimage) {
File repFile = new File(currentFolder.getVars().get("representingFile").toString());
File folderImage = new File(outputDirectory, "folderimage.jpg");
if(engine.getImageLinking().equals(AlbumBean.LINK_ORIGINALS) || currentFolder.getRepresentingAlbumObject().isUseOriginal()) IO.copyFile(repFile, folderImage);
else {
AlbumImage ai = new AlbumImage(repFile, engine);
ai = ai.applyFilters(JAFilter.ALL_PRESCALE_STAGE).applyFilters(JAFilter.ALL_POSTSCALE_STAGE);
ai = ai.scaleToFit(new Dimension(maxImageWidth, maxImageHeight));
ai.saveImage(folderImage, engine.getQualityPercent());
}
}
The trick is to apply both prescale and postscale filters. No need for 140 lines of code.
Well, now I have two very different methods of getting where I want to go, both of which seem to be able to handle every case I've tested. One technique (this one) involves having the skin generate its own slide image at the folder level, to match the image in the sub-sub-sub folder where it might actually reside.
The other involves grabbing the imagePath to the folder image and manipulating the string it returns to fix some things - strip off the leading folder name, and remove slides/ if the linking is to originals. And one more twist that I had to deal with - if you choose Force JPEG writing, but also Link to originals, mydog.png lands in the output with its original name, but imagePath thinks it should be mydog.jpg.
I just have to figure out which one is more efficient, and which is easier to maintain.
|
|
|
Posts:
7,103
Registered:
31-Jan-2006
|
|
|
Re: Getting the slide image for a folder
Posted:
26-Mar-2018 22:50
in response to: JeffTucker
|
|
|
Well, now I have two very different methods of getting where I want to go, both of which seem to be able to handle every case I've tested.
With one odd little exception, in which case a more elaborate method is called for: the application of the "pixelate" effect. I can "feel" why that one's different.
But no matter. I think the imagePath route, for all its quirks, is the more robust. In that case, I'm never generating my own slide image. Whatever the jAlbum core produces, that's the image I'm pointing to from the parent (or grandparent or great-grandparent) folder. It does involve some gyrations, but they're not horrible: if(useFolderimage) {
fiPath = currentFolder.getVars().get("imagePath");
fiPath = fiPath.substring(fiPath.indexOf('/') + 1);
if(engine.getImageLinking().equals(AlbumBean.LINK_ORIGINALS) || currentFolder.getRepresentingAlbumObject().isUseOriginal()) {
fiPath = fiPath.replace("/" + engine.getSlideDirectory() + "/", "/");
fiName = currentFolder.getVars().get("representingFile").getName();
if(engine.isForceJPEGWriting()) fiPath = fiPath.substring(0, fiPath.lastIndexOf("/") + 1) + fiName;
else if(fiName.toLowerCase().endsWith(".gif")) fiPath = fiPath.substring(0, fiPath.lastIndexOf("/") + 1) + fiName;
}
}
}
Edited by: jGromit on 27-Mar-2018 08:57. For anyone following along from the cheap seats, you need to account for the weird behavior of the imagePath variable when combined with linking to originals, forcing JPEG writing, and PNG's or GIF's. Quite bizarre.
|
|
|
Posts:
572
Registered:
27-Sep-2003
|
|
|
Re: Getting the slide image for a folder
Posted:
27-Mar-2018 02:43
in response to: JeffTucker
|
|
|
You need to replace ai = ai.applyFilters(JAFilter.ALL_PRESCALE_STAGE).applyFilters(JAFilter.ALL_POSTSCALE_STAGE);
ai = ai.scaleToFit(new Dimension(maxImageWidth, maxImageHeight));
with ai = ai.applyFilters(JAFilter.ALL_PRESCALE_STAGE);
ai = ai.scaleToFit(new Dimension(maxImageWidth, maxImageHeight));
ai = ai.applyFilters(JAFilter.CLOSEUPS_POSTSCALE_STAGE);
ai = ai.applyFilters(JAFilter.ALL_POSTSCALE_STAGE);
or more simply ai = ai.applyFilters(JAFilter.ALL_PRESCALE_STAGE).scaleToFit(new Dimension(maxImageWidth, maxImageHeight)).applyFilters(JAFilter.CLOSEUPS_POSTSCALE_STAGE).applyFilters(JAFilter.ALL_POSTSCALE_STAGE);
Your requirements are different from mine, so I still need to use the complex method; I won't bore you with the details here.
Edited by: ctwist on 26-Mar-2018 20:48
|
|
|
|
Legend
|
|
Forum admins
|
|
Helpful Answer
|
|
Correct Answer
|
|