It is currently April 28th, 2024, 11:57 am

Problem with Image AspectRatio and Trimming

Get help with creating, editing & fixing problems with skins
User avatar
thatsIch
Posts: 446
Joined: August 7th, 2012, 9:18 pm

Problem with Image AspectRatio and Trimming

Post by thatsIch »

I'm getting an Image with unknown size through a webparser
So I want to scale it to fix a certain area lets say

W = 200
H = 100

now when I say

PreserveAspectRatio = 1

it fille fit the biggest possible area within the 200x100 without resizing
But I want it to fit all 200x100 with cutting the edges off
(for example the original is 150x150 it would get resized to 200x200 and cut of on top and bottom to 200x100)

Is this possible without using 2 meters (first to resize and second to trim) or is lua the only master to solve this problem? No easy fix?
Alex Becherer

Re: Problem with Image AspectRatio and Trimming

Post by Alex Becherer »

it is possible with either lua or section variables. but both ways you will need two images, as the ascpect ratio can not be calculated from a fixed size image.
Alex Becherer

Re: Problem with Image AspectRatio and Trimming

Post by Alex Becherer »

actually, if you say unknown size you mean the aspect ratio is also unknown?
with a fixed aspect ratio it would be possible to do with one image.
User avatar
thatsIch
Posts: 446
Joined: August 7th, 2012, 9:18 pm

Re: Problem with Image AspectRatio and Trimming

Post by thatsIch »

ratio is also unknown

I have random image
but it should fix perfectly in 200x100
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Problem with Image AspectRatio and Trimming

Post by Mordasius »

thatsIch wrote:Is this possible without using 2 meters (first to resize and second to trim) or is lua the only master to solve this problem?
I suspect lua is going to be the easiest way and you might get some ideas from this thread.
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Problem with Image AspectRatio and Trimming

Post by MerlinTheRed »

I guess the easiest way is to create an "invisible" image that lets you determine the actual image size. Then you get the height and width of that invisible image using the new section variables. Then you can determine what to put into the CropBorders setting of the image you want to display. I found it easiest to use the center as the origin here (put a 5 at the end). Then you have something like

CropBorders=-[Image:W]/2, -[Image:W]/2*0.5, [Image:W], [Image:W]*0.5, 5 if the image has to be cut off at the top and bottom, or

CropBorders=-[Image:H]/2*2, -[Image:H]/2, [Image:H]*2, [Image:H], 5 If the image has to be cropped left and right.

The 0.5 and 2 multipliers are there because you wanted an image that is twice as wide as it is high.

The only problem I see with this approach is that Rainmeter might report a width and height of 0 for an invisible image. I remember that there used to be a problem like this. If this happens, you can try giving the "invisible" image an alpha value of 1, or shift it out of the skin by using TransformationMatrix=1;0;0;1;10000;0 on the image.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
Alex Becherer

Re: Problem with Image AspectRatio and Trimming

Post by Alex Becherer »

MerlinTheRed wrote: The only problem I see with this approach is that Rainmeter might report a width and height of 0 for an invisible image. I remember that there used to be a problem like this. If this happens, you can try giving the "invisible" image an alpha value of 1, or shift it out of the skin by using TransformationMatrix=1;0;0;1;10000;0 on the image.
exactly. that happens when you set Hidden=1.
you can make it truly invisible with setting ImageAlpha=0 though.
make it a little smaller than the final image with PreserveAspectRatio=1, place it behind the final image and you are fine.
User avatar
thatsIch
Posts: 446
Joined: August 7th, 2012, 9:18 pm

Re: Problem with Image AspectRatio and Trimming

Post by thatsIch »

MerlinTheRed wrote:I guess the easiest way is to create an "invisible" image that lets you determine the actual image size. Then you get the height and width of that invisible image using the new section variables. Then you can determine what to put into the CropBorders setting of the image you want to display. I found it easiest to use the center as the origin here (put a 5 at the end). Then you have something like

CropBorders=-[Image:W]/2, -[Image:W]/2*0.5, [Image:W], [Image:W]*0.5, 5 if the image has to be cut off at the top and bottom, or

CropBorders=-[Image:H]/2*2, -[Image:H]/2, [Image:H]*2, [Image:H], 5 If the image has to be cropped left and right.

The 0.5 and 2 multipliers are there because you wanted an image that is twice as wide as it is high.

The only problem I see with this approach is that Rainmeter might report a width and height of 0 for an invisible image. I remember that there used to be a problem like this. If this happens, you can try giving the "invisible" image an alpha value of 1, or shift it out of the skin by using TransformationMatrix=1;0;0;1;10000;0 on the image.
ya but I dont know where it has to be cropped xD
and while you are at it, might you explain me how that works?
I thought crop from x,y to w right and h down of the image
but why would I take the negative of the image-height as X etc?
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Problem with Image AspectRatio and Trimming

Post by KreAch3R »

Funny enough, I am currectly developing such a skin myself. I first went native Rainmeter, like you, but given that my image was huge and I was worried about memory hogs if I let it "hidden" using positions or Transformation matrixes (nice touch Merlin), I came up with an AutoIt addon. Take look:

Image

Original image: 2300x1533 | Aspect Ratio ~ 1,5
Scaled: 2300x~1300 | Aspect ratio ~ 1,77 (or 16/9 widescreen)

It works currently only with "up - down" crop. The next step is deciding automatically where it should crop, and then display it in widescreen or portrait mode. It will be included in Edge, when fully working. :)
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
thatsIch
Posts: 446
Joined: August 7th, 2012, 9:18 pm

Re: Problem with Image AspectRatio and Trimming

Post by thatsIch »

KreAch3R wrote:Funny enough, I am currectly developing such a skin myself. I first went native Rainmeter, like you, but given that my image was huge and I was worried about memory hogs if I let it "hidden" using positions or Transformation matrixes (nice touch Merlin), I came up with an AutoIt addon. Take look:

Image

Original image: 2300x1533 | Aspect Ratio ~ 1,5
Scaled: 2300x~1300 | Aspect ratio ~ 1,77 (or 16/9 widescreen)

It works currently only with "up - down" crop. The next step is deciding automatically where it should crop, and then display it in widescreen or portrait mode. It will be included in Edge, when fully working. :)
you wouldnt mind posting your current code so I can get a grasp of it. Havent worked with autoit yet so I dont know how to use it with RM.

Maybe I should add a more background information why I want such thing and what for
Im currently developing a Skin for a RSS Reader with "infinite" auto support for feeds.
each feed has max 25 entries displayed from its feed and some feeds have images in them.
So I want these images as preview for my feeds cause eye looks faster than it reads =)

Preview: