Closed simon-clematide closed 6 months ago
Hi @simon-clematide , on it!
I observed a few cases where the longest line was an outlier. Then maybe too many regions would be reduced to less than 100%. 100% is the cap anyways. Maybe a more robust width reduction would be to take the line average of the region width and reduce the CSS width only when it is more than 20% smaller.
In the transcription view, text lines are scaled to some value to match the column witdth. This makes short lines scale a lot more than "normal" lines. I think the scaling should be done relative to the longest line to look more natural (see below).
https://impresso-project.ch/app/issue/waeschfra-1868-09-20-a/view?sq=Cg8QAhgHIAEqB2vDqHR0w6kKAhgC&p=3&articleId=i0003&text=1
I asked ChatGPT
Here is what ChatGPT suggests:
To compute the relative width of IIIF images based on their dimensions and scale them relative to the largest image part, you will first need to understand the dimensions of each image, and then apply a scaling factor based on the width of the largest image. This allows each image to be displayed proportionally in a viewer where the largest image defines the full width.
Here are the steps to compute and apply this scaling:
1. Retrieve the Image Dimensions
Each IIIF URL provides a hint to the dimensions of the image through its path. In the examples you provided, the dimensions are specified in the URL segment that looks like
x,y,width,height
. For example:583,1327,245,57
138,1416,1144,2221
This indicates the image part width as 245 pixels for the shorter title and 1144 pixels for the longer text lines.
2. Determine the Largest Image Width
From the dimensions you retrieve, determine the largest width. In your example, that would be 1144 pixels from the longer text lines.
3. Calculate Scaling Factor
The scaling factor for each image is calculated by dividing the width of each image by the width of the largest image. This factor will then be used to set the relative widths in CSS or HTML.
4. Apply the Scaling Factor
You can apply the scaling factor directly in your HTML by adjusting the
width
style property. Here is how you can compute and apply it:Computation
Scaling
For the shorter title: [ \text{Scaling Factor} = \left(\frac{245}{1144}\right) \times 100\% \approx 21.41\% ]
HTML Implementation
Adjust the
width
style attribute in your HTML to reflect these scaling factors:5. Conclusion
This approach ensures that all images are scaled proportionally relative to the largest image, making the visual representation coherent and visually balanced. This method also keeps the aspect ratio of the images intact, which is important for readability and aesthetics in your newspaper viewer.
Applying the 21% in the browser gives: