It is currently March 28th, 2024, 2:19 pm

Simple Image Meter Skin uses 70mb+ of ram

Get help with creating, editing & fixing problems with skins
Post Reply
noirZ
Posts: 12
Joined: November 16th, 2011, 7:18 pm

Simple Image Meter Skin uses 70mb+ of ram

Post by noirZ »

So i updated an old skin i sought help for here before to this today:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureImageSite]
Measure=Plugin
Plugin=WebParser
URL=http://photography.nationalgeographic.com/photography/photo-of-the-day/
RegExp="(?siU)<meta property="og:image" content="http://yourshot.nationalgeographic.com/u/(.*)""
UpdateRate=3600

[MeasureImage]
Measure=Plugin
Plugin=WebParser
URL=http://yourshot.nationalgeographic.com/u/[MeasureImageSite]/?.jpg
StringIndex=1
Download=1
DownloadFile=Natgeo.jpg

[MeterOne]
Meter=Image
MeasureName=MeasureImage
PreserveAspectRatio=1
W=200
LeftMouseUpAction=[[MeasureImage]]
DynamicVariables=1
I usually check how much ram a new skin uses because I like to keep things efficient
and I saw that it causes rainmeter.exe to use a little over 70mb more than without it.
I would like to figure out why but I have no idea how to go about it, I suspect that it is because it downloads the full res image
and not just the small one that is displayed when you actually go to http://photography.nationalgeographic.com/photography/photo-of-the-day/
(but I can't find the link to that downsized version in the source, thanks js I guess).
However I also don't see why a 1,3mb (in the case of today) picture would cause rainmeter to use 70mb+ of ram..
Any suggestions/ideas?

//edit: Another question just popped up, will this actually change to the new picture once the website updates? i had to set DownloadFile or it wouldn't work because the output is just a file called "index" that rainmeter can't open because of the missing .jpg file extension.
Last edited by noirZ on April 27th, 2017, 4:10 pm, edited 1 time in total.
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Re: Simple Image Meter Skin uses 70mb+ of ram

Post by Bananorpion »

I have not tested your code, but the RAM used to display or even load an image is not proportional to its storage space, I don't know the exact formula but that's clearly likely exponential. (Which means if your picture is 130kb, the RAM used won't be 7Mb, more like 500kb or less I would say.)
I can't say that I'm sure, though. Days ago I worked on a 9Mo picture, took 220Mb in memory with Gimp, which doesn't confirm the exponential growth, compared to yours. There are probably factors I don't know. (I don't deal with memory usage, usually.)
noirZ
Posts: 12
Joined: November 16th, 2011, 7:18 pm

Re: Simple Image Meter Skin uses 70mb+ of ram

Post by noirZ »

So I would have to find a way to downsize the source image i guess..
btw, just opening it with windows' photo viewer takes 40mb of ram and not downsizing it via W= makes it use 95mb, just thought that's kinda interesting.
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Re: Simple Image Meter Skin uses 70mb+ of ram

Post by Bananorpion »

To automatically downsize an image after downloading it, you may use ImageMagick. Never tried it on Windows, but very useful for image-processing automation.
Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Re: Simple Image Meter Skin uses 70mb+ of ram

Post by Bekarfel »

The RAM used by the skin is proportional (and in this case is equal) to the uncompressed size of the image.

Code: Select all

width  height   image area
5,358 * 3,577  =  19,165,556 

   image     byte     image 
   area      depth    size
19,165,556  *  4  =   76,662,264 bytes
I agree with you that the only way to make the skin smaller is to make the image smaller
noirZ
Posts: 12
Joined: November 16th, 2011, 7:18 pm

Re: Simple Image Meter Skin uses 70mb+ of ram

Post by noirZ »

hmmm, i guess there is no way to get the link from the javascript that has the links to the smaller images?
Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Re: Simple Image Meter Skin uses 70mb+ of ram

Post by Bekarfel »

It appears that the actual image URLs are not located within the page itself, so there is no way to parse the page to extract the image locations. The og:image tag you're parsing on is actually metadata for the Open Graph Protocol. If you want the actual image URLs, you'll need to parse the endpoint gallery .json that is in the page, around line 245 - 250,

Code: Select all

<script type="text/json" data-pestle-options>{"id":"bfEHZlpl", "firstImage":"http://www.nationalgeographic.com/photography/photo-of-the-day/2017/04/winter-tram-romania",
"endpoint":"http://www.nationalgeographic.com/photography/photo-of-the-day/_jcr_content/.gallery.2017-04.json",
"previewAspectRatio":"three-two", "showTitles":true, "showCaptions":true, "showCredits":true, "showAssetSources":true, "backgroundColor":"#f3f1f1"}</script>
I should note that I strongly believe that this json is changed on a routine basis, so relying on it solely will cause the script to not update at some point
Post Reply