It is currently October 9th, 2024, 2:56 am

Get Exif information

Tips and Tricks from the Rainmeter Community
Darth Weber
Posts: 6
Joined: October 5th, 2017, 6:28 am

Re: Get Exif information

Post by Darth Weber »

Jeff wrote: October 18th, 2020, 6:25 pm

Code: Select all

[FilePath]
Measure=String
String="%USERPROFILE%\Downloads\canon_hdr_YES.jpg"

[GetExifData]
Measure=Plugin
Plugin=RunCommand
Parameter=magick identify -format '%[EXIF:*]' "[FilePath]"
OutputType=ANSI
DynamicVariables=1
This code is brought by today's sponsor, ImageMagick (because it has this dandy fancy function)
(i know it's a scratching-the-left-part-of-your-head-using-the-right-hand situation but this is a fix for school and work computers that blocked powershell through group policies)
Thanks for this hint!

I am trying to add some caption to an image, but i failed in adding these exif informations to a string. Can you help me with an example ? I am trying:

Code: Select all

[Caption]
Meter=String
MeasureName=MeasurePic
X=5
Y=-20R
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=9
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Angle=(Rad(-1))
Text=%1

[GetExifData]
Measure=Plugin
Plugin=RunCommand
Parameter=magick identify -format '%[EXIF:Model]' "[MeasurePic]"
OutputType=ANSI
DynamicVariables=1

[Caption2]
Meter=String
MeasureName=GetExifData
X=5
Y=-40R
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=9
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Angle=(Rad(-1))
Text=%1
[caption] ist working ans displays the filename, but caption2 ist just empty
User avatar
Yincognito
Rainmeter Sage
Posts: 8390
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Get Exif information

Post by Yincognito »

Darth Weber wrote: January 14th, 2021, 1:48 pmI am trying to add some caption to an image, but i failed in adding these exif informations to a string. Can you help me with an example ? I am trying:

Code: Select all

[Caption]
Meter=String
MeasureName=MeasurePic
X=5
Y=-20R
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=9
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Angle=(Rad(-1))
Text=%1

[GetExifData]
Measure=Plugin
Plugin=RunCommand
Parameter=magick identify -format '%[EXIF:Model]' "[MeasurePic]"
OutputType=ANSI
DynamicVariables=1

[Caption2]
Meter=String
MeasureName=GetExifData
X=5
Y=-40R
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=9
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Angle=(Rad(-1))
Text=%1
[caption] ist working ans displays the filename, but caption2 ist just empty
Take a look at the note from the RunCommand plugin's page from Rainmeter's manual here - your GetExifData measure needs to be told to run, otherwise it just sits there and does nothing.

Sample code:

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[MeasurePic]
Measure=String
String="D:\Images\Wallpapers\- Single -\Zeus OSX Earth Space.jpg"
UpdateDivider=-1
OnUpdateAction=[!UpdateMeasure GetExifData][!CommandMeasure GetExifData "Run"][!UpdateMeter Caption2][!Redraw]

[GetExifData]
Measure=Plugin
Plugin=RunCommand
Parameter=magick identify -format '%[EXIF:PixelXDimension]' "[MeasurePic]"
OutputType=ANSI
RegExpSubstitute=1
Substitute="(?siU)(?:^'|'$)":""
DynamicVariables=1

---Meters---

[Reference]
Meter=Image
Y=50

[Caption]
Meter=String
MeasureName=MeasurePic
X=5
Y=-20R
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=9
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Angle=(Rad(-1))
Text=%1

[Caption2]
Meter=String
MeasureName=GetExifData
X=5
Y=-40R
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=9
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Angle=(Rad(-1))
Text=%1
Result:
EXIF Width.jpg
Notes:
- I added my own [MeasurePic] measure, since I don't have your full code; obviously, if yours works fine, there's no need to add it again, except the bangs mentioned below
- I placed the bangs that update and run the [GetExifData] measure, update the related meter and redraw the skin in the OnUpdateAction option of [MeasurePic], but, depending on your workflow, they can be placed in another option (e.g. a LeftMouseUpAction, etc.) as long as that is executed after [MeasurePic] gets its value (so that the command makes sense)
- for some reason, the EXIF:Model didn't work for me (or maybe my image didn't have the needed data), so I used EXIF:PixelXDimension (basically, the image width value) instead; naturally, this can be adjusted as desired
- I slightly formatted the [GetExifData] measure's output in a regular expression enabled Substitute, in order to remove the single quotes aka the apostrophes from the beginning and end of the string; this part can also be adjusted to your liking, regular expressions (you can test various regex patterns online on sites like this one) are a powerful tool that can be used to manipulate strings
- I added a dummy [Reference] meter to prevent the caption meters from displaying outside of the skin (since I lacked the meter that you positioned your captions relative to); this is only needed in my sample skin, I suppose everything is positioned correctly in your environment

P.S. Take care not to run [GetExifData] more times that it actually needs to (for example, you don't want ImageMagick to be run every second on every skin update, you just want it to run whenever [MeasurePic] gets a new value). That is the reason why I used an UpdateDivider of -1 in the triggering measure, i.e. [MeasurePic]. Again, you should adapt the approach to your scenario, if needed.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Darth Weber
Posts: 6
Joined: October 5th, 2017, 6:28 am

Re: Get Exif information

Post by Darth Weber »

That works perfect, thank you so much !
User avatar
Yincognito
Rainmeter Sage
Posts: 8390
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Get Exif information

Post by Yincognito »

Darth Weber wrote: January 18th, 2021, 4:43 pm That works perfect, thank you so much !
My pleasure, friend. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth