How to show width and height of image

Post Reply
OldRadioGuy
Posts: 75
Joined: 15 May 12 3:44
Location: Austin, Texas, USA
Contact:

How to show width and height of image

Post by OldRadioGuy »

Is there a macro available to set a New Custom Field to show the dimensions of an image? I haven't found one in the drop-down options and other entries I have tried don't work.
G8DHE
Posts: 704
Joined: 21 Aug 17 12:58

Re: How to show width and height of image

Post by G8DHE »

Its available under the "Image" line either both or individual;
image dimensions.jpg
image dimensions.jpg (234.06 KiB) Viewed 1444 times
Geoff Mather (G8DHE)
OldRadioGuy
Posts: 75
Joined: 15 May 12 3:44
Location: Austin, Texas, USA
Contact:

Re: How to show width and height of image

Post by OldRadioGuy »

Thanks, but clicking on +New Custom Field does not show these options. Where are you finding what you have shown?
Photo Supreme 2024; DxO PhotoLab; Affinity Photo; PhotoLine; Luminar Neo; macOS Sonoma; Mac M2 Studio
G8DHE
Posts: 704
Joined: 21 Aug 17 12:58

Re: How to show width and height of image

Post by G8DHE »

Why are you trying to create a new field, your looking to select an existing field from the metadata to display as text below the image?
Start by displaying an image thumbnail,
now click on the 2nd icon along the bottom of the thumbnail window "Thumbnail style",
in the Definition pane, click on a new line or wherever you want to put the new info.,
click the drop down arrow, select the "Image" fields, now select the field you want in this case "Image dimension (width x height)",
click outside the styling box to update the display, then finally when your happy with the Definition you have created click the three bar option to save the Custom style as needed.

On mine ;
image dimensions on mine.jpg
image dimensions on mine.jpg (344.1 KiB) Viewed 1415 times
You can see I have two added lines which give me date time, image size, then the second line shows dimensions followed by count of Labels by Category (Hert published this some time ago on the forum).
The two lines of display are coded as;
Line one;
%xmp:exif:DateTimeOriginal{encode=html} <font family="tahoma" color="#CCFFFF00">%ImageFileSizeShort</font>

Line two;
<font family="tahoma" color="#CCAAFF00">%ImageDimension{encode=html} </font>
%code

procedure PreparePropsForCats(AProps: TCatalogItemProps; ACats: TCatalogPropCategories);
var
i: Integer;
ACat: TCatalogPropCategory;
begin
for i := 0 to AProps.Count - 1 do
begin
AProps.Items.Name := '';
ACat := TCatalogPropCategory.Create(nil);
try
if PublicCatalog.EnumCategoryForProp(AProps.Items, ACat) then
AProps.Items.Name := ACat.GUID;
finally
ACat.Free;
end;
end;
end;

function AddCatMarker(ACat: TCatalogPropCategory; AProps: TCatalogItemProps);
var
i, ACount: Integer;
begin
// add a color marker, when one of the props is from the category
result := '';

ACount := 0;
for i := 0 to AProps.Count - 1 do
begin
if AProps.Items.Name = ACat.GUID then
ACount := ACount + 1;
end;

if (ACount > 0) {and (ACat.UseColor)} then
result := '<span alt="' + ACat.CategoryName + ' (' + IntToStr(ACount) + ')' + '" ><font style="background-color: ' + ACat.Color + '; color: ' + ACat.FontColor + '; width:30%;" width="50%">&nbsp;&nbsp;' + IntToStr(ACount) + '&nbsp;&nbsp;</font></span>';
end;

var
ACats: TCatalogPropCategories;
AProps: TCatalogItemProps;
i: Integer;
begin
result := '';

ACats := TCatalogPropCategories.Create(TCatalogPropCategory, '');
AProps := TCatalogItemProps.Create(TCatalogItemProp, '');
try
PublicCatalog.EnumCategories(ACats, False);
PublicCatalog.EnumPropsForImage(ImageItem, AProps, False, False);

PreparePropsForCats(AProps, ACats);

for i := 0 to ACats.Count - 1 do
result := result + AddCatMarker(ACats.Items, AProps)
finally
AProps.Free;
ACats.Free;
end;
end;
%/code
Geoff Mather (G8DHE)
OldRadioGuy
Posts: 75
Joined: 15 May 12 3:44
Location: Austin, Texas, USA
Contact:

Re: How to show width and height of image

Post by OldRadioGuy »

That's really what I wanted, but I overlooked the button. Got it now. I'm a happy camper! Thanks again for your efforts to help!
Photo Supreme 2024; DxO PhotoLab; Affinity Photo; PhotoLine; Luminar Neo; macOS Sonoma; Mac M2 Studio
RobiWan
moderator
Posts: 221
Joined: 03 Nov 17 8:14

Re: How to show width and height of image

Post by RobiWan »

G8DHE wrote: 18 Feb 24 20:47 followed by count of Labels by Category (Hert published this some time ago on the forum).
The code will not work here - I don't know why but it displays nothing here. Code from your entry produces error here (maybe because is not as code inserted here). Code from repository displays nothing.
G8DHE
Posts: 704
Joined: 21 Aug 17 12:58

Re: How to show width and height of image

Post by G8DHE »

I see that Hert has now added to the list under "From Repository" might be best to select it from there ? But it looks like you have also found it there, just tried it and it worked OK for me maybe something different for you I'm working under Windows 10 and 11 .
Geoff Mather (G8DHE)
RobiWan
moderator
Posts: 221
Joined: 03 Nov 17 8:14

Re: How to show width and height of image

Post by RobiWan »

I have Windows 11 and PostgreSQL Version. (I will check if there is a difference to SQLite version)
Post Reply