gigaboy Posted September 18, 2019 Share Posted September 18, 2019 I use a third party image caching service for a website I manage. One of the interesting features is their ability to "stretch" a photo without distortion, to horizontally fill the website window. This is done by taking the last vertical column(s?) of pixels at the left and right ends of the original, and duplicating them repeatedly to fill the space. See "0.jpg" for an original image, and "1.jpg" for the "stretched" version. I'm curious as to the steps involved to create this affect inside AP. Quote Link to comment Share on other sites More sharing options...
firstdefence Posted September 18, 2019 Share Posted September 18, 2019 I'm assuming you have resized the canvas to accommodate the stretched selection. Select the Column marquee tool Select the far right edge of the image Copy and paste, this will create a new pixel layer Duplicate that layer about 4 -5 times and group them Select the Move tool and stretch the group. The reason for duplication is because of transparency, you can see that effect by not duplicating the layer in step 4. You don't have to select the far right edge you could select any column and stretch it. Dan C 1 Quote iMac 27" 2019 Somona 14.3.1, iMac 27" Affinity Designer, Photo & Publisher V1 & V2, Adobe, Inkscape, Vectorstyler, Blender, C4D, Sketchup + more... XP-Pen Artist-22E, - iPad Pro 12.9 (Please refrain from licking the screen while using this forum) Affinity Help - Affinity Desktop Tutorials - Feedback - FAQ - most asked questions Link to comment Share on other sites More sharing options...
GarryP Posted September 18, 2019 Share Posted September 18, 2019 @firstdefence Can you explain the “because of transparency” bit please? I can see there’s something that looks like a kind of transparency gradient there on the stretched layer but I don’t understand why it’s there. Or, to put it another way, I don’t have any transparency in the original copied pixels so why do I have some in the stretched pixels? Also, is this expected behaviour for all/most photo manipulation software or is it just an Affinity Photo thing? Wosven 1 Quote Link to comment Share on other sites More sharing options...
firstdefence Posted September 18, 2019 Share Posted September 18, 2019 @GarryP Re transparency, if you make a column selection and copy/paste it to a pixel layer, then increase it's width you don't end up with a solid you end up with a semi transparent blur for want of a better word. So in this example image I'll make a selection and stretch that 1 pixel selection I select the column marquee tool and make a single pixel column Next I copy/paste to a pixel layer and then stretch that pixel column, notice the transparency Duplicating the pixel layer solids the pixels up. Just tried this in photoshop and while it shows a solid stretch, upon applying the stretch it goes from solid to transparent. See images below. This is just prior to the transform being applied in Photoshop This is after the transform has been applied in Photoshop Quote iMac 27" 2019 Somona 14.3.1, iMac 27" Affinity Designer, Photo & Publisher V1 & V2, Adobe, Inkscape, Vectorstyler, Blender, C4D, Sketchup + more... XP-Pen Artist-22E, - iPad Pro 12.9 (Please refrain from licking the screen while using this forum) Affinity Help - Affinity Desktop Tutorials - Feedback - FAQ - most asked questions Link to comment Share on other sites More sharing options...
telemax Posted September 18, 2019 Share Posted September 18, 2019 Affine.mp4 GarryP, Alfred, carl123 and 1 other 3 1 Quote Non-destructive Mask https://forum.affinity.serif.com/index.php?/topic/150439-non-destructive-mask/Image layer & Pixel layer https://forum.affinity.serif.com/index.php?/topic/146720-image-layer-and-pixel-layer/Brushes | Stars https://forum.affinity.serif.com/index.php?/topic/135202-brushes-stars/ Link to comment Share on other sites More sharing options...
GarryP Posted September 19, 2019 Share Posted September 19, 2019 firstdefence: I saw that this produced transparency but my question was about why I get the transparency. Where does the transparency come from and why is it applied when the original pixels had no transparency? In other words, which workflows benefit from the software automatically adding the transparency (even though I haven’t told the software to do it)? In your examples from Photoshop I can see that the opacity dwindles from left to right which looks like it could be useful in some cases – merging photos, etc. – but Affinity Photo seems to have the highest opacity in the middle of the stretched layer – there’s a kind of ‘opacity bump’ in the middle (see attached image) – which doesn’t look very useful to me. telemax: That’s a really nice tip. Thanks for sharing that. Wosven 1 Quote Link to comment Share on other sites More sharing options...
firstdefence Posted September 19, 2019 Share Posted September 19, 2019 Telemax is a good tip but when you move the slider you're removing the left side of the image. unclipping the canvas doesn't work. You need a few more steps to complete the process. Duplicate the image layer and change it's opacity to 70% Apply the Affine filter to the bottom layer Align the top layer with the bottom layer Unclip the canvas Merge visible or just group Export Quote iMac 27" 2019 Somona 14.3.1, iMac 27" Affinity Designer, Photo & Publisher V1 & V2, Adobe, Inkscape, Vectorstyler, Blender, C4D, Sketchup + more... XP-Pen Artist-22E, - iPad Pro 12.9 (Please refrain from licking the screen while using this forum) Affinity Help - Affinity Desktop Tutorials - Feedback - FAQ - most asked questions Link to comment Share on other sites More sharing options...
GarryP Posted September 19, 2019 Share Posted September 19, 2019 That technique didn’t work for me. I think there could be some steps and/or settings missing as the left-hand side of my attempt has a noticeable transparency, and “Align the top layer with the bottom layer” seems a bit fiddly to do manually. I think an easier way is to just resize the canvas width – with top-right as the origin, to give a gap to the left – and then use the Affine transform as shown above. (Shame the offset can’t be specified in pixels (I tried -200px and it didn’t work) but it’s usable up to a point.) Quote Link to comment Share on other sites More sharing options...
telemax Posted September 19, 2019 Share Posted September 19, 2019 4 hours ago, GarryP said: why I get the transparency Because the Bilinear method is used for resampling. Switching to Nearest is not a solution, Bilinear will be applied during layer rasterization or during export. Of course you can export with Nearest mode, but it will spoil other image details. Nearest_test.mp4 firstdefence 1 Quote Non-destructive Mask https://forum.affinity.serif.com/index.php?/topic/150439-non-destructive-mask/Image layer & Pixel layer https://forum.affinity.serif.com/index.php?/topic/146720-image-layer-and-pixel-layer/Brushes | Stars https://forum.affinity.serif.com/index.php?/topic/135202-brushes-stars/ Link to comment Share on other sites More sharing options...
telemax Posted September 19, 2019 Share Posted September 19, 2019 As in Affine, texture fill has Repeat mode. Bitmap_Fill.mp4 Dan C 1 Quote Non-destructive Mask https://forum.affinity.serif.com/index.php?/topic/150439-non-destructive-mask/Image layer & Pixel layer https://forum.affinity.serif.com/index.php?/topic/146720-image-layer-and-pixel-layer/Brushes | Stars https://forum.affinity.serif.com/index.php?/topic/135202-brushes-stars/ Link to comment Share on other sites More sharing options...
GarryP Posted September 20, 2019 Share Posted September 20, 2019 Ah, so if I understand it correctly – albeit at a very basic level – when I stretch a pixel layer the software uses the “View Quality” setting in Preferences to determine how the ‘new’ (virtual?) pixels are created. And, because “Bilinear” does some maths that naturally produces transparency, that’s why I get a transparency in some of the ‘new’ pixels; the “opacity bump” coming simply from how the “Bilinear” function works. Also, while I can switch to a View Quality of “Nearest Neighbour” and do a stretch without the transparency coming in, as soon as I rasterise this newly-stretched layer it will automatically be resampled using “Bilinear” no matter what the View Quality setting is. If this is all correct (up to a point), my first thought is that “View Quality” might not be the best name for this setting as it’s a bit confusing. If it was renamed to something like “Resampling Method” it could give the user a little more information about what it was used for, rather than “View Quality” which is a bit ‘generalised’ and doesn’t really give much information. My next thought is that this “View Quality” setting doesn’t seem to be used consistently. When I stretch a pixel layer this setting is used but when I rasterise a pixel layer this setting is ignored. This doesn’t seem right to me but I could well be missing more information. A further thought is that the Photoshop stretching seems to do a nicer job in this specific case – single pixel stretching, or, less specifically, stretching the ‘side’ of a layer – where the transparency is added in a more natural way (with no “opacity bump” in the middle). Could a setting or something be added to allow the user to choose what they want to do in these instances? (The context bar has plenty of room.) Anyway, thanks for giving some extra information on this. Even if I don’t understand it completely it gives me something to think about. Quote Link to comment Share on other sites More sharing options...
Fixx Posted September 20, 2019 Share Posted September 20, 2019 That transparency problem has been discussed before in these forums. Personally I think it is an error in programmer thinking – if selection consists of whole pixels there should be no reason for transparent edges. If we want transparency, there is feather feature for it. Sofa Gas Rue 1 Quote Link to comment Share on other sites More sharing options...
telemax Posted September 20, 2019 Share Posted September 20, 2019 2 hours ago, GarryP said: my first thought is that “View Quality” might not be the best name for this setting as it’s a bit confusing. If it was renamed to something like “Resampling Method” I think because when you rescale a raster layer in Nearest mode, there is a loss of quality. Rescaling test.afphoto Rescaling_test.mp4 Quote Non-destructive Mask https://forum.affinity.serif.com/index.php?/topic/150439-non-destructive-mask/Image layer & Pixel layer https://forum.affinity.serif.com/index.php?/topic/146720-image-layer-and-pixel-layer/Brushes | Stars https://forum.affinity.serif.com/index.php?/topic/135202-brushes-stars/ Link to comment Share on other sites More sharing options...
firstdefence Posted September 20, 2019 Share Posted September 20, 2019 Simplest effective method is to use the Mesh Warp tool. Resize canvas to desired length. Select the Mesh Warp Tool Double click next to the right top corner node to add a freeze line. Select both right-side corner nodes being careful to not select the nodes you have just added (Nodes will turn black when selected) Click on one of the black nodes and pull across to cover the transparent area created earlier. Bear in mind you cannot constrain the mesh tool, well as far as I am aware. On the context menu you can select different resample methods Bilinear included. Santos, MEB, GarryP and 1 other 4 Quote iMac 27" 2019 Somona 14.3.1, iMac 27" Affinity Designer, Photo & Publisher V1 & V2, Adobe, Inkscape, Vectorstyler, Blender, C4D, Sketchup + more... XP-Pen Artist-22E, - iPad Pro 12.9 (Please refrain from licking the screen while using this forum) Affinity Help - Affinity Desktop Tutorials - Feedback - FAQ - most asked questions Link to comment Share on other sites More sharing options...
GarryP Posted September 20, 2019 Share Posted September 20, 2019 That’s a really great technique. Thanks for sharing. In the tests I’ve done it doesn’t really matter that you can’t snap the mesh to the corners of the canvas as the corners of the mesh can be brought out from the corners of the canvas a bit (maybe with a little curve) for a slightly more natural look. Also, a quick swipe down with a large In-painting brush afterwards seems to give a better transition. And a bit of a Live Gaussian Blur (with Preserve Alpha) on the affected area helps too. My example below didn’t take much time to do (it needs much more work but what you get for just a little work is good). firstdefence 1 Quote Link to comment Share on other sites More sharing options...
mmaaxx Posted March 16, 2022 Share Posted March 16, 2022 they totally should fix this. Quote Link to comment Share on other sites More sharing options...
NotMyFault Posted March 16, 2022 Share Posted March 16, 2022 On 9/19/2019 at 10:42 AM, GarryP said: Where does the transparency come from and why is it applied when the original pixels had no transparency? In other words, which workflows benefit from the software automatically adding the transparency (even though I haven’t told the software to do it)? Hi, even if this question has been raised a long time ago, I think it has not been answered, and bothers many users (including myself The answer is actually simple if you use a black/white pattern: When you stretch this pattern by factor 2, all white becomes gray (255->191), and all black becomes muddy (0-64): All hard edges get blurred, as the DPI get 1/2 of original. When you replace white by transparency, you will see that resampling unavoidably will get what you observe: all pixels will get blurred with neighbouring pixels. The more you stretch, the more you blur. Copying pixels to get a larger source area (from 1 to 4 or 8 pixel) will mitigate the blurriness, as it then blurs pixels of same color. So it is just mathematics, and nothing intended to support any specific workflow. Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 iPad Air Gen 5 (2022) A2589 Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps. Link to comment Share on other sites More sharing options...
NotMyFault Posted March 16, 2022 Share Posted March 16, 2022 4 hours ago, mmaaxx said: they totally should fix this. Could you elaborate ? There is nothing broken, it works as designed, so what should be fixed? you may raise a feature request if you think a functionality is missing or you want a shortcut. As @telemax and @firstdefence have shown in earlier posts, you can get the requested function today by a few simple steps. Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 iPad Air Gen 5 (2022) A2589 Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.