It is currently April 26th, 2024, 7:22 pm

Rainmeter Image cropping

Get help with creating, editing & fixing problems with skins
TheOnlyMobyDank
Posts: 6
Joined: October 24th, 2015, 6:02 am

Rainmeter Image cropping

Post by TheOnlyMobyDank »

I am trying to crop an image with the ImageCrop command and I want it cropped with the bottom left as the origin, however, the only thing i can get it to do is crop from the middle... if I crop from anywhere else, The image does not display.
Here is the Working Code:

Code: Select all

ImageCrop=((#W#+1)*47),0,10,500,5
and here is the code that makes it crop from the bottom left and not display:

Code: Select all

ImageCrop=((#W#+1)*47),0,10,500,4
I don't know if I'm crazy but the only thing that changes here is the origin... Any help would be much appreciated.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Rainmeter Image cropping

Post by Mor3bane »

I do not think you are grasping the ImageCrop properly:
ImageCrop
Crops out and uses a defined part of the image. The option value should be in the form: X, Y, W, H, Origin.

Origin is optional and can be set to one of the following:

1 : Top left (default)
2 : Top right
3 : Bottom right
4 : Bottom left<------ why can't you utilise this property?
5 : Center

A way to envision what ImageCrop is doing is:

ImageCrop=-50,-30,100,60,5<-------In this format?

Start at the Origin of 5 or "Center". Then move -50 pixels left (negative number is left, positive number is right) and -30 pixels up (negative number is up, positive number is down). Then capture 100 pixels of width, and 60 pixels of height, and that is the new image. This will crop and use 100 X 60 pixels of the center of the image.

Notes:

ImageCrop is done before any resizing of the image with the W and H general meter options. If W and H are set, the new "cropped" image will be resized to fit.

If W and H are not defined, ImageCrop will change the size of the entire meter container to the size of the "cropped" image.
Your equation is really unnecessary unless it is actually simplifying your code.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rainmeter Image cropping

Post by jsmorley »

You have to wrap your head around how it works:

https://docs.rainmeter.net/manual/meters/general-options/image-options/#ImageCrop
A way to envision what ImageCrop is doing is:

ImageCrop=-50,-30,100,60,5

Start at the Origin of 5 or "Center". Then move -50 pixels left (negative number is left, positive number is right) and -30 pixels up (negative number is up, positive number is down). Then capture 100 pixels of width, and 60 pixels of height, and that is the new image. This will crop and use 100 X 60 pixels of the center of the image.
So let's use this image as an example. It's 450 X 605:
lampoon.jpg
First, let put a mostly transparent copy of that image up so we can see how the cropped "pieces" look on top of it. I'm using X and Y on the meter(s) to keep the pieces in the same spot they would be in the original image.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterOriginal]
Meter=Image
ImageName=#@#Images\lampoon.jpg
ImageAlpha=90
Then lets start with the top left

Code: Select all

[MeterTopLeft]
Meter=Image
X=0
Y=0
ImageName=#@#Images\lampoon.jpg
ImageCrop=0,0,200,200,1
So we start at an origin of "top left / 1". Then we move 0 pixels of X, 0 pixels of Y and grab 200 width and 200 height.
TopLeft.jpg
Then top right

Code: Select all

[MeterTopRight]
Meter=Image
X=250
Y=0
ImageName=#@#Images\lampoon.jpg
ImageCrop=-200,0,200,200,2
So we start at an origin of "top right / 2". Then we move -200 (left) pixels of X, 0 pixels of Y and grab 200 width and 200 height.
TopRight.jpg
Then bottom left

Code: Select all

[MeterBotLeft]
Meter=Image
X=0
Y=405
ImageName=#@#Images\lampoon.jpg
ImageCrop=0,-200,200,200,4
So we start at an origin of "bottom left / 4". Then we move 0 pixels of X, -200 (up) pixels of Y and grab 200 width and 200 height.
BotLeft.jpg
Then bottom right

Code: Select all

[MeterBotRight]
Meter=Image
X=250
Y=405
ImageName=#@#Images\lampoon.jpg
ImageCrop=-200,-200,200,200,3
So we start at an origin of "bottom right / 3". Then we move -200 (left) pixels of X, -200 (up) pixels of Y and grab 200 width and 200 height.
BotRight.jpg
And last, center

Code: Select all

[MeterCenter]
Meter=Image
X=125
Y=203
ImageName=#@#Images\lampoon.jpg
ImageCrop=-100,-100,200,200,5
So we start at an origin of "center / 5". Then we move -100 (half, left) pixels of X, -100 (half, up) pixels of Y and grab 200 width and 200 height.
Center.jpg
And finally, all together

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterOriginal]
Meter=Image
ImageName=#@#Images\lampoon.jpg
ImageAlpha=90

[MeterBotLeft]
Meter=Image
X=0
Y=405
ImageName=#@#Images\lampoon.jpg
ImageCrop=0,-200,200,200,4

[MeterBotRight]
Meter=Image
X=250
Y=405
ImageName=#@#Images\lampoon.jpg
ImageCrop=-200,-200,200,200,3

[MeterTopLeft]
Meter=Image
X=0
Y=0
ImageName=#@#Images\lampoon.jpg
ImageCrop=0,0,200,200,1

[MeterTopRight]
Meter=Image
X=250
Y=0
ImageName=#@#Images\lampoon.jpg
ImageCrop=-200,0,200,200,2

[MeterCenter]
Meter=Image
X=125
Y=203
ImageName=#@#Images\lampoon.jpg
ImageCrop=-100,-100,200,200,5
All.jpg
Conclusion:

So in effect the X and Y in

ImageCrop=X, Y, Width, Height, Origin

are moving the origin some number of pixels X and Y starting at the origin defined as the last parameter. Then you cut out and keep some number of pixels of width and height, and that will be the result.

A way to think of it is:

ImageCrop=MoveOriginXPixels, MoveOriginYPixels, KeepWidth, KeepHeight, StartingOrigin
You do not have the required permissions to view the files attached to this post.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Rainmeter Image cropping

Post by Mor3bane »

What I found when using this is that the Width and Height can be used to "zoom in" on an image.

By decreasing the W & H decreases the amount of pixels the crop will show.

Similarly, the X & Y can choose where you would be "zooming" based on the origin.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
TheOnlyMobyDank
Posts: 6
Joined: October 24th, 2015, 6:02 am

Re: Rainmeter Image cropping

Post by TheOnlyMobyDank »

Great! I didn't realize that the cropping always originated from the top left... I thought that's what the origin was controlling. Thank you both for your help!
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rainmeter Image cropping

Post by jsmorley »

TheOnlyMobyDank wrote:Great! I didn't realize that the cropping always originated from the top left... I thought that's what the origin was controlling. Thank you both for your help!
Huh? It doesn't....