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


Permlink Replies: 20 - Pages: 2 [ 1 2 | Next ] - Last Post: 27-May-2013 13:08 Last Post By: ctwist
ctwist

Posts: 554
Registered: 27-Sep-2003
Auto-regenerate individual images
Posted: 10-Dec-2009 00:55
 
  Click to reply to this thread Reply
If some characteristics of an image change (e.g. the brightness filter), Jalbum automatically regenerates the image when "make - changes" is processed.

Is there a public method that accomplishes this? I generate some images within the skin, and I would like to replicate this feature.
davidekholm

Posts: 3,683
Registered: 18-Oct-2002
Re: Auto-regenerate individual images
Posted: 12-Dec-2009 15:06   in response to: ctwist in response to: ctwist
Helpful
  Click to reply to this thread Reply
Good question. There probably should be. This is how it's implemented:
Jalbum first uses a private method of the AlbumBean called getImageSettingsHash() to get a magic number that is made up of the global settings that affect images like global image filters, image- and thumbnail sizes, scaling quality, progressive move and amount of global sharpness applied. This hash code/magic number is compared with a stored copy (stored in the .jalbum/.info file of the root album object. If the numbers differ, then Jalbum does a "Make all" operation.

If the numbers are equal, Jalbum only reprocesses individual images that are missing or that have had their image filters modified. This check isn't as clever as with global settings, but clever enough: It compares file dates between the generated file and original file, but not only the original file, but also its corresponding .jalbum/filename.info file of the image. If either of those dates are newer than of the generated file, then it is reprocessed.

Now, can you use this scheme for your own code? Yes but there is some work to it: The getImageSettingsHash() method of the AlbumBean is private, but you can call it if your call setAccessibility(true) first. Second, to compare if an individual file needs updating, call lastModified() on the generated file and compare it with getLastModified() of the AlbumObject for the original file. To get an AlbumObject for the original file, use
JalbumContext.getInstance().getAlbumObjectFactory().createInstance(currentFile, imageDirectory);
 

I aim to simplify this API for the future. You shall have direct access to all relevant AlbumObjects and why not add an isDirty() method directly to AlbumObjects that does these date checks for you.
TomCee

Posts: 382
Registered: 11-Jul-2005
Re: Auto-regenerate individual images
Posted: 13-Dec-2009 00:49   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Now, can you use this scheme for your own code? Yes but there is some work to it: The getImageSettingsHash() method of the AlbumBean is private, but you can call it if your call setAccessibility(true) first.

David/Chris: be aware this only works in onload.bsh, not in compiled java.

On a side-note, David: I really like to have an emergency setting for make-all, which doesn't do anything 'magic', just does what it advertises: make-all

regards,
Tom
davidekholm

Posts: 3,683
Registered: 18-Oct-2002
Re: Auto-regenerate individual images
Posted: 14-Dec-2009 00:14   in response to: TomCee in response to: TomCee
 
  Click to reply to this thread Reply
Do you want the skin to be able to override Jalbum's way of figuring out between "Make all" and "Make changes"?
jGromit

Posts: 7,697
Registered: 31-Jan-2006
Re: Auto-regenerate individual images
Posted: 14-Dec-2009 00:19   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
David, I'm finding that "Make all" just flat-out isn't working. I've got my preferences set to "Clean old output files on make all," but choosing "Make All" is not reprocessing the images. It's acting exactly like "Make Changes."

Edit: more info... It's working properly in WinXP, but not in Win7. This is beginning to feel familiar - I'm seeing other instances in which Jalbum is refusing to delete things in Win7.

Edited by: EarlyOut on 13-Dec-2009 18:31
TomCee

Posts: 382
Registered: 11-Jul-2005
Re: Auto-regenerate individual images
Posted: 14-Dec-2009 00:24   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
99,9% of the jalbum users will be perfectly happy with the intelligent way jalbum decides what to rebuild. But we, developers, want to have full control. When we say make all, it needs to 'make all'

regards,
Tom
RoniM

Posts: 11
Registered: 17-Nov-2005
Re: Auto-regenerate individual images
Posted: 14-Dec-2009 02:37   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Try to run jalbum as admin on win7, that might help. Just right click JAlbum icon and choose "Run as Administrator".

I find this stupid especialy when this makes difference even if you are only user and admin, still you do not get all permissions...
jGromit

Posts: 7,697
Registered: 31-Jan-2006
Re: Auto-regenerate individual images
Posted: 14-Dec-2009 03:13   in response to: RoniM in response to: RoniM
 
  Click to reply to this thread Reply
Yup, "Run as administrator" results in "Make All" behaving properly again. It doesn't cure the other weird behaviors I've been seeing however, including the inability to delete folders or the incomplete deletion of an entire project.
RoniM

Posts: 11
Registered: 17-Nov-2005
Re: Auto-regenerate individual images
Posted: 14-Dec-2009 12:08   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
At least something works ;-)
davidekholm

Posts: 3,683
Registered: 18-Oct-2002
Re: Auto-regenerate individual images
Posted: 14-Dec-2009 14:57   in response to: RoniM in response to: RoniM
 
  Click to reply to this thread Reply
Sounds like we have some experimenting with Windows7 coming up for us :-(
jGromit

Posts: 7,697
Registered: 31-Jan-2006
Re: Auto-regenerate individual images
Posted: 14-Dec-2009 15:07   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Sounds like we have some experimenting with Windows7 coming up for us :-(

You're not alone - I'm still feeling my way around it. I have to say that I like it, however. So far, it's been very stable, and the couple of Jalbum glitches are things that are easy to work around until a more robust solution is found.

(Not a Jalbum thing, but I've found that Win7 doesn't do as much "pestering" as Vista. Still, I ended up turning off user access control. Every time I launched ccleaner, Win7 would ask me if I wanted to let the application make changes to the system. Well, I just clicked on it, didn't I? Does that give you a hint? In short, they still haven't made that safety feature context-sensitive - if the user has launched an app, he wants to let it do its thing, and there's no need to prompt!)
ctwist

Posts: 554
Registered: 27-Sep-2003
Re: Auto-regenerate individual images
Posted: 15-Dec-2009 02:59   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
To get back to the original point.....

Yes, an isDirty() method would be useful. However, the technique needs a bit more work:
  • Include an album image that is small enough that it doesn't need to be resized.
  • Generate the album. The output image has the same creation date as the original image.
  • Increase the brightness. Regenerate. The output image is brighter and its modified timestamp is "now".
  • Undo the brightness filter. Regenerate. The output image is not changed; it is still brighter than the source image. It should have reverted to be the same as the source image.

If the source image needs to be resized, the preceding test works correctly. In the final step, the image is recreated with the original brightness.
davidekholm

Posts: 3,683
Registered: 18-Oct-2002
Re: Auto-regenerate individual images
Posted: 15-Dec-2009 14:40   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
I can't get it to fail by undoing a filter and then pressing "Make Jalbum" again. It reprocesses the right image again. Did you perhaps have the wrong image cached in your browser?
ctwist

Posts: 554
Registered: 27-Sep-2003
Re: Auto-regenerate individual images
Posted: 16-Dec-2009 03:09   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
I watched the output image in Windows Explorer, so caching does not cause any confusion.

Image bounds are 512x512. The source jpg image is 512x459, updated on 6 Dec 2009 2:00pm.

1) Generate the album. The output image has timestamp 6 Dec 2009 2:00pm. CORRECT

2) Increase the brightness of the image by 30%. Apply. Make changes. The output image is brighter and has timestamp 15 Dec 2009 8:50pm. CORRECT

3) Undo the brightness change. The preview returns to its original appearance. Make changes. The output image is still brighter and has timestamp 15 Dec 2009 8:50pm. WRONG

In test "3", the image should have been re-generated with the original brightness, and its timestamp should have been 15 Dec 2009 8:53pm (or it should have been the same as in test "1").
davidekholm

Posts: 3,683
Registered: 18-Oct-2002
Re: Auto-regenerate individual images
Posted: 16-Dec-2009 18:13   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
I'm sorry to say I can't reproduce that problem. It works fine when I try here.
Legend
Forum admins
Helpful Answer
Correct Answer

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