Displaying image information in file panel

You want to talk about Far Manager, but don't know where to turn?
User avatar
buniak_a_h
Posts: 4268
Joined: Sat 20 Apr, 2013 00:17
Location: Санкт-Петробад
Has thanked: 222 times
Been thanked: 644 times
Contact:

Displaying image information in file panel

Post by buniak_a_h »

Latest post of the previous page:

2useven10, I was also thinking about the version number ;-
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

I updated it, and it fixed the lua explorer output, but the PictureColumns script still doesn't work, as you can see in the screenshot.
LELuaOutput.jpg
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

Wait, no! It's working now!
image.png
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

I had the wrong script in place.
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

Now if I want to put the width and height in separate columns, so I can sort them individually, how do I do that? I tried modifying the script, but it's not working. It gives me two empty columns.
  1. local MediaInfo_GUID = '919C1FC6-A571-4642-99DF-BDACE840ED18'
  2.  
  3.  
  4.  
  5. local function GetPicSize(FilePath)
  6.  
  7.   local ok, n, _, Vals = Plugin.SyncCall(MediaInfo_GUID, FilePath,'{Width,Height}', false)
  8.  
  9.   if ok and n == 2 then
  10.  
  11.     return Vals[0], Vals[1]
  12.  
  13.   end
  14.  
  15. end
  16.  
  17.  
  18.  
  19. ContentColumns {
  20.  
  21.   filemask = "*.webp,*.bmp,*.gif,*.jpg,*.png,*.psd,*.jpe,*.jpeg,*.cdr,*.wmf,*.ai,*.cmx,*.svg,*.emf,*.ico,*.icl,*.cur,*.ani,*.dds,*.tif,*.tiff,*.tga,*.pcx,*.pic,*.jpc,*.jp2,*.j2k,*.mng,*.psp,*.xbm,*.xpm,*.dib,*.rle,*.lbm,*.iff,*.pbm,*.pgm,*.ppm,*.ras,*.sgi,*.rgb,*.bw,*.wbmp,*.dcx,*.cel,*.flc,*.fli,*.spr,*.fpx";
  22.  
  23.  
  24.  
  25.   GetContentFields = function(ColNames)
  26.  
  27.     for j, v in ipairs(ColNames) do
  28.  
  29.       if v == "Width" or v == "Height" then
  30.  
  31.           return true
  32.  
  33.       end
  34.  
  35.     end
  36.  
  37.   end;
  38.  
  39.  
  40.  
  41.   GetContentData = function(FilePath, ColNames)
  42.  
  43.     local data = {}
  44.  
  45.     local picWidth, picHeight = GetPicSize(FilePath)
  46.  
  47.     for j, v in ipairs(ColNames) do
  48.  
  49.       if v == 'Width' then
  50.  
  51.         data[j] = picWidth or ''
  52.  
  53.       end
  54.  
  55.       if v == 'Height' then
  56.  
  57.         data[j] = picHeight or ''
  58.  
  59.       end
  60.  
  61.     end
  62.  
  63.     return next(data) and data
  64.  
  65.   end;
  66.  
  67. }
Last edited by old_gregg on Thu 06 Oct, 2022 21:40, edited 4 times in total.
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

Here's the file panel mode I made:
image.png
Last edited by old_gregg on Thu 06 Oct, 2022 21:41, edited 1 time in total.
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

Thank you so much for your help, you guys! I love Far and I've never messed around with scripts and only a little with plugins all these years I've been using it.
2useven10
Posts: 5232
Joined: Mon 07 Sep, 2009 10:40
Has thanked: 18 times
Been thanked: 315 times

Displaying image information in file panel

Post by 2useven10 »

lua arrays are 1-based by default, so you should use Vals[1], Vals[2]
Last edited by 2useven10 on Thu 06 Oct, 2022 21:44, edited 2 times in total.
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

Still nothing.
  1. local MediaInfo_GUID = '919C1FC6-A571-4642-99DF-BDACE840ED18'
  2.  
  3.  
  4.  
  5. local function GetPicSize(FilePath)
  6.  
  7.   local ok, n, _, Vals = Plugin.SyncCall(MediaInfo_GUID, FilePath,'{Width,Height}', false)
  8.  
  9.   if ok and n == 2 then
  10.  
  11.     return Vals[1], Vals[2]
  12.  
  13.   end
  14.  
  15. end
  16.  
  17.  
  18.  
  19. ContentColumns {
  20.  
  21.   filemask = "*.webp,*.bmp,*.gif,*.jpg,*.png,*.psd,*.jpe,*.jpeg,*.cdr,*.wmf,*.ai,*.cmx,*.svg,*.emf,*.ico,*.icl,*.cur,*.ani,*.dds,*.tif,*.tiff,*.tga,*.pcx,*.pic,*.jpc,*.jp2,*.j2k,*.mng,*.psp,*.xbm,*.xpm,*.dib,*.rle,*.lbm,*.iff,*.pbm,*.pgm,*.ppm,*.ras,*.sgi,*.rgb,*.bw,*.wbmp,*.dcx,*.cel,*.flc,*.fli,*.spr,*.fpx";
  22.  
  23.  
  24.  
  25.   GetContentFields = function(ColNames)
  26.  
  27.     for k, v in ipairs(ColNames) do
  28.  
  29.       if v == "Width" or v == "Height" then
  30.  
  31.           return true
  32.  
  33.       end
  34.  
  35.     end
  36.  
  37.   end;
  38.  
  39.  
  40.  
  41.   GetContentData = function(FilePath, ColNames)
  42.  
  43.     local data = {}
  44.  
  45.     local picWidth, picHeight = GetPicSize(FilePath)
  46.  
  47.     for k, v in ipairs(ColNames) do
  48.  
  49.       if v == 'Width' then
  50.  
  51.         data[k] = picWidth or ''
  52.  
  53.       end
  54.  
  55.       if v == 'Height' then
  56.  
  57.         data[k] = picHeight or ''
  58.  
  59.       end
  60.  
  61.     end
  62.  
  63.     return next(data) and data
  64.  
  65.   end;
  66.  
  67. }
Last edited by old_gregg on Thu 06 Oct, 2022 22:27, edited 1 time in total.
User avatar
buniak_a_h
Posts: 4268
Joined: Sat 20 Apr, 2013 00:17
Location: Санкт-Петробад
Has thanked: 222 times
Been thanked: 644 times
Contact:

Displaying image information in file panel

Post by buniak_a_h »

old_gregg, line #8 must be:
local ok, n, _, Vals = Plugin.SyncCall(MediaInfo_GUID, FilePath,'{Width,Height}') (last argument false is excess)
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

I got it!
  1. local MediaInfo_GUID = '919C1FC6-A571-4642-99DF-BDACE840ED18'
  2.  
  3.  
  4.  
  5. local function GetPicSize(FilePath)
  6.  
  7.   local ok, n, _, Vals = Plugin.SyncCall(MediaInfo_GUID, FilePath,'{Width,Height}')
  8.  
  9.   if ok and n == 2 then
  10.  
  11.     return string.format('%6s', string.gsub(Vals[1], '[^%d]+', '')), string.format('%6s', string.gsub(Vals[2], '[^%d]+', ''))
  12.  
  13.   end
  14.  
  15. end
  16.  
  17.  
  18.  
  19. ContentColumns {
  20.  
  21.   filemask = "*.webp,*.bmp,*.gif,*.jpg,*.png,*.psd,*.jpe,*.jpeg,*.cdr,*.wmf,*.ai,*.cmx,*.svg,*.emf,*.ico,*.icl,*.cur,*.ani,*.dds,*.tif,*.tiff,*.tga,*.pcx,*.pic,*.jpc,*.jp2,*.j2k,*.mng,*.psp,*.xbm,*.xpm,*.dib,*.rle,*.lbm,*.iff,*.pbm,*.pgm,*.ppm,*.ras,*.sgi,*.rgb,*.bw,*.wbmp,*.dcx,*.cel,*.flc,*.fli,*.spr,*.fpx";
  22.  
  23.  
  24.  
  25.   GetContentFields = function(ColNames)
  26.  
  27.     for k, v in ipairs(ColNames) do
  28.  
  29.       if v == "Width" or v == "Height" then
  30.  
  31.           return true
  32.  
  33.       end
  34.  
  35.     end
  36.  
  37.   end;
  38.  
  39.  
  40.  
  41.   GetContentData = function(FilePath, ColNames)
  42.  
  43.     local data = {}
  44.  
  45.     local picWidth, picHeight = GetPicSize(FilePath)
  46.  
  47.     for k, v in ipairs(ColNames) do
  48.  
  49.       if v == 'Width' then
  50.  
  51.         data[k] = picWidth
  52.  
  53.       end
  54.  
  55.       if v == 'Height' then
  56.  
  57.         data[k] = picHeight
  58.  
  59.       end
  60.  
  61.     end
  62.  
  63.     return next(data) and data
  64.  
  65.   end;
  66.  
  67. }
Last edited by old_gregg on Thu 06 Oct, 2022 22:48, edited 1 time in total.
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

Thanks a lot for your help! This is awesome!
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

Wait, except for I want to sort them now. How do I do that?
User avatar
buniak_a_h
Posts: 4268
Joined: Sat 20 Apr, 2013 00:17
Location: Санкт-Петробад
Has thanked: 222 times
Been thanked: 644 times
Contact:

Displaying image information in file panel

Post by buniak_a_h »

old_gregg wrote: Thu 06 Oct, 2022 22:50 Wait, except for I want to sort them now. How do I do that?
See articles about Panel.LoadCustomSortMode, Panel.Panel.SetCustomSortMode and Panel.CustomSortMenu (in macroapi_manual.en.chm)

I have script for sort panel items by genre, author, album, duration etс. This script uses plugin Media info too. But:
  1. This script contains russian strings.
  2. It is intended for use in a panel module
You can use it as example (change keywords in plugin call and labels)
MediaSortModes.lua
Example
(3.65 KiB) Downloaded 58 times
old_gregg
Posts: 46
Joined: Fri 01 May, 2015 16:04
Has thanked: 10 times
Been thanked: 1 time

Displaying image information in file panel

Post by old_gregg »

Cool! Where do I find macroapi_manual.en.chm?
User avatar
HaRT
Moderator
Posts: 10867
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 221 times
Been thanked: 358 times

Displaying image information in file panel

Post by HaRT »

old_gregg wrote: Fri 07 Oct, 2022 00:08 Where do I find macroapi_manual.en.chm?
It's installed with FAR unless you excluded Documentation in the installer.
Фар есть инструмент, а не нянька. © 2009 DrKnS
Post Reply

Return to “General Discussions”