MasterHowToLearn

MasterHowToLearn

"Damn I Should've Done That Years Ago" (5): Choose "Image > Stretch > Filled" for Image Occlusion Items

2019-07-06 2019-07-07 2020-11-17

source

I learned this the hard way. Don’t make the same mistake like I did.

Basic Understanding for Image Occlusion Items

In order to understand why you should choose “Image > Stretch > Filled” for all image occlusion items, you need to understand that when creating such an item, there are at least two components: Image component and the picture

Basic_Understanding

The image component is the gray area; the picture is contained in this image component. In this case, the picture size is smaller than the image component.

In the component menu, Image > Stretch, there are three options: Normal, Proportional, Filled

Options

These options change the relationship between the image component and the picture size. From the official guideline:

Stretch - determine how the image is made to fit the image component:

Normal - display the image in its original size

Proportional - stretch the image proportionally to the maximum size within the image component

Filled - display the current image stretched to the full width and the full height of the current component. If the image is smaller or larger than the image component, it will be shrunk or stretched to the appropriate size. To retain the proportions, use Proportional instead

My old method

When I created an image occlusion item, I had been choosing “Image > Stretch > Normal” for my images. With Normal, the image doesn’t become blurry and the image ratio doesn’t get distorted. I didn’t understand why; it just “worked” and I didn’t give it much thought.

Comparison.png

When pasting, the default setting is Proportional. You can see the picture quality of Normal is the best among the three. The picture is in its original size and I only need to make the image component bigger. At the same time, you can also see that the image component doesn’t scale with the picture size.

Problems surfaced

Under "Image > Stretch > Normal", if you change the SuperMemo’s window size, not only is that the picture doesn’t scale according to the windows size, the red rectangle would not follow the picture. The picture, image component and the red rectangle are like three independent and unrelated components: one does not follow the other; yet it doesn’t make sense because they all should scale according to each other.

Resize_Comparison

Resize.png

I knew this a long time ago and I didn’t think it would create much of a problem, because I didn’t normally change the window size. This doesn’t create a problem as long as you don’t change the window size.

However, recently I’ve changed from a 14” laptop to a 17.3” laptop with the windows scaling changed from 150% to 125%. Even if I don’t change the SuperMemo window size, all the red rectangles were out of place. This is a nightmare since I have hundreds of image occlusion items. I looked for solutions on SuperMemopedia and came upon this Unruly Rectangles in Image Occlusion

Make sure that:

1. Picture is full stretched (Image : Display : Fill) - if it is distorted, modify the size of the image component (option on the component menu, e.g. available with the right click over the picture)

2. The template/element is Scaled (option on the element menu, e.g. available with the right click on the navigation bar)

With those two, all scaling of the image and the template/element will ensure the same relative position of the rectangle in reference to the picture.

So it was unwise or ignorant of me to use “Image > Stretch > Normal” at the very beginning. I was completely clueless and it took me days to fix the image occlusion item ONE BY ONE.

Why not fix it incrementally? First, if I encountered a broken (non-corresponding between picture and red rectangle) image occlusion item, I would see the answer immediately and this would ruin the repetition history. How would I rate that item if the answer revealed itself? Also, it would constantly frustrate me whenever I see these broken image occlusion items.

How I Fixed My Broken Image Occlusion Items

Solution for original image quality with proper scaling

When you use the image occlusion template, after pasting the image:

After_pasting.png

To call the Component menu, right click at the image.

1. Component menu: Image > Fit Size > The actual size of the bitmapped image. Result:

First_Pic_Size.png

I have no idea why the image component moved and the size of the red rectangle changed.

2. Component menu: Image > Fit Size > The actual size of the bitmapped image

Second_Pic_Size.png

I also have no idea why it takes two same operations for the image component to perfectly fits the picture size. Sometimes one will do; but mostly two times.

3. Component menu: > Image > Stretch > Filled (Shortcut: Ctrl+Shift+Q from the default Proportional setting)

4. Move the red rectangle

Solution_result.png

As you can see, no matter how you change the SuperMemo window size, the red rectangle and the picture are both changed correspondingly:

Resize_ok.png

Caveat 1:

Right Click > Image > Stretch > Filled (Shortcut: Ctrl+Shift+Q)

Image > Fit Size > The actual size of the bitmapped image

This order doesn’t work. After Fit Size, the stretch would change from Filled to Normal.

Caveat 2:

If the picture is bigger than the image component, you can edit the picture by Right Click the image > File > Edit File (Ctrl+ F9) to downsize it in MS Paint. Why not drag the image component bigger to contain the picture? You can but if your image is still larger than the maximized image component, it will be down-scaled and look blurry.

Caveat 3:

My solution differs from the official answer in that I don’t need to choose Image > Scaling for every picture. For some reason all of them are already scaled 100%. Your Mileage May Vary and you may need to do this.

Autohotkey Scripts

I used some autohotkey scripts to minimize key presses and to batch process them. These scripts are very simple yet effective in alleviating the frustration and saving time.

This is my autohotkey script to quickly choose Image > Fit Size > The actual size of the bitmapped image. You need to point the mouse location within the image component before pressing the a key to trigger the script.

ImageOcclusionEditor

SuperMemo user alexis created this amazing ImageOcclusionEditor. If you create a lot of image occlusion items, this tool is invaluable. However, if you have a lot of broken image occlusion items like I did, this tool doesn’t help because it creates new image occlusion items, not fixing existing broken ones.

Will this “bug” ever be solved?

In this discussion, possibly answered by the creator of SuperMemo:

There is no mechanism for component parenting at the moment in SuperMemo. It would require adding new fields to the database (component’s parent) and would be bug-prone (there are many issues with parenting in Delphi that has caused many problems to SuperMemo in the past). Perhaps the simplest improvement would be to force image scaling in accordance with the element scaling property (after confirmation)?

Closing Remarks

If you’re early on in your SuperMemo journey, congratulations as you now won’t make the same mistake I did. If you found out you have the same issue, then you probably have no other option other than biting the bullet and fixing it. I thought as long as I didn’t change the SuperMemo window size, it would be fine… until I changed the window scaling. The sooner you turn all the image occlusion items into this proper-scaling version, the better.