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


Permlink Replies: 8 - Pages: 1 - Last Post: 29 Oct 21, 21:09 Last Post By: JeffTucker Threads: [ Previous | Next ]
ctwist

Posts: 651
Registered: 27-Sep-2003
Problems with user-defined variables
Posted: 29 Oct 21, 03:12
 
  Click to reply to this thread Reply
I am struggling with user-defined variables that a user has entered for a specific image.

I will illustrate with an example:

I have a panoramic image. In my skin, I want it to exceed the image width bound, and provide sideways scrolling. So in the Edit window, I added a variable for the image:
maxImageWidth=50000
This had no effect; the generated image was reduced to the album's image bounds.

I assumed that I was doing something wrong in the skin, so I generated the album in Minimal 8. This became more interesting. While processing the image with the variable override, it crashed at slide.htt line 81. After some digging, I discovered that, for this image, the class type of borderWidth (yes, that's not a typo; not "imageWidth") was "String", whereas for the other images, the class type was "Primitive".

The solution was to cast borderWidth to int. I.e. on line 81, change
borderWidth
to
(borderWidth.getClass().getSimpleName().equals("String") ? Integer.parseInt(borderWidth) : borderWidth)
i.e.
<footer class="autohide" id="caption" style="max-width: <%= imageWidth - (2 * (borderWidth.getClass().getSimpleName().equals("String") ? Integer.parseInt(borderWidth) : borderWidth)) - (4 * borderPadding) %>px">
This fixed the exception, but the generated image was still limited to the image bounds. As far as this example goes, I am not concerned about this; Minimal is probably not intended to support panoramas.

End of the example.

Looking beyond this example:
  • (misinformation removed)

I'm not finished with other related problems, but let's sort these out first.

Edited by: ctwist on 29 Oct 2021, 08:53
Misinformation removed
JeffTucker

Posts: 8,105
Registered: 31-Jan-2006
Re: Problems with user-defined variables
Posted: 29 Oct 21, 03:40   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
I have a panoramic image. In my skin, I want it to exceed the image width bound, and provide sideways scrolling. So in the Edit window, I added a variable for the image:
maxImageWidth=50000
This had no effect; the generated image was reduced to the album's image bounds.

The classic response: works when I do it.

Using virtually any of my skins, I can add several images, including one whose native dimensions are 3872x773px. The image bounds (the skin's default) are 1600x750. But for that one image, I enter 10000 as maxImageWidth. The resulting slide image is 3872x773px, as expected, whereas all the others are, for example, 1120x750px.

If set the maxImageWidth to 3000, instead, the resulting slide image is 3000x599px.

ETA: Same result with Minimal and Tiger.
ctwist

Posts: 651
Registered: 27-Sep-2003
Re: Problems with user-defined variables
Posted: 29 Oct 21, 04:17   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
I stripped my project down to just the offending image, and it generates. I didn't change any project settings. If I generate with all the other images, it fails.

It shouldn't be like this.

I will have to dig deeper.
ctwist

Posts: 651
Registered: 27-Sep-2003
Re: Problems with user-defined variables
Posted: 29 Oct 21, 04:48   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
Aha! I have found the culprit.

I stripped the project down to the erroring image in a first level subfolder, followed by 2 subsequent images. On a subsequent image (not necessarily the next one), add a user variable "borderWidth:0". This "bleeds" through to the earlier image and causes the error.

It didn't occur to me that this could happen, so I made an assumption!

Please don't tell me "it works here"!

Edited by: ctwist on 29 Oct 2021, 00:29
Reworded to remove ambiguity.
JeffTucker

Posts: 8,105
Registered: 31-Jan-2006
Re: Problems with user-defined variables
Posted: 29 Oct 21, 09:32   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
I also get a crash with Minimal in that case, though the maxImageWidth still works properly for its image - I'm not seeing any of the "bleeding" problem you describe, though with multi-threading it's tough to sort that out. But let's focus on the crash with borderWidth, which is clearly the heart of the problem.

In Atom, I tried stashing this in slide.htt:
<% something = borderWidth * 5; %>
That crashes, even though borderWidth is declared in SkinModel.java as an int. But if I put the same thing in common.css, instead, I get no crash. And if I put it in init.bsh (without the <% and %>, of course), I also get no crash.

This all feels very familiar, but I can't put my finger on it.
RobM

Posts: 3,888
Registered: 4-Aug-2006
Re: Problems with user-defined variables
Posted: 29 Oct 21, 10:46   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
  • I question why jAlbum delivers all user defined variables as strings. If a skin invents its own variable, this is reasonable, but if the user provides a variable whose name matches one of the pre-defined jAlbum variables that can be overridden, shouldn't these be presented to the skin as the same class type as the built-in variable (i.e. int)?
Image dimension user variables, like maxImageWidth, should not be string. See http://jalbum.net/forum/message.jspa?messageID=315066#315066
JeffTucker

Posts: 8,105
Registered: 31-Jan-2006
Re: Problems with user-defined variables
Posted: 29 Oct 21, 14:18   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
It gets even stranger. The inability to multiple borderWidth by 5 is due to the fact that, at this stage of the processing, jAlbum thinks it's a String. And yet, if I try this:
something = Integer.parseInt(borderWidth);
It crashes with an error that indicates it believes that it's already an int!
 Error in method invocation: Static method parseInt( int ) not found in class'java.lang.Integer' 
The only thing that works (remember, we're talking about slide.htt, here, not elsewhere) is:
something = (Integer.parseInt(borderWidth.toString())) *  5;
In the immortal words of Anna Russell, "I'm not making this up, you know!"
RobM

Posts: 3,888
Registered: 4-Aug-2006
Re: Problems with user-defined variables
Posted: 29 Oct 21, 20:28   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Isn't this because borderWidth is defined as an int within the skin, but the skin doesn't have a custom gui. With a gui, the user variable would be converted to an int, not left as a string.
JeffTucker

Posts: 8,105
Registered: 31-Jan-2006
Re: Problems with user-defined variables
Posted: 29 Oct 21, 21:09   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
That would certainly be the safer way to handle something like this.
Legend
Forum admins
Helpful Answer
Correct Answer

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