Author Topic: Autolisp to get bitmap pixel values  (Read 1590 times)

0 Members and 1 Guest are viewing this topic.

Ben Clark

  • Newt
  • Posts: 83
Autolisp to get bitmap pixel values
« on: August 07, 2019, 04:57:50 PM »
What is the best way to get a bitmap's pixels (monochrome in this instance) into a lisp list. I'm wanting to be able to select an image file, extract it's pixel values (0-255 monochrome for each pixel)  into a list, and use them for input into a neural network (don't ask why  :wink:)

any help would be much apprecitated.

Lee Mac

  • Seagull
  • Posts: 12296
  • London, England
Re: Autolisp to get bitmap pixel values
« Reply #1 on: August 07, 2019, 05:15:19 PM »
I've written a program to perform this task (and used it to produce this program, and these icons); I intend to publish it to my site at some point, but I haven't had the time to finish the code.

Ben Clark

  • Newt
  • Posts: 83
Re: Autolisp to get bitmap pixel values
« Reply #2 on: August 07, 2019, 05:17:59 PM »
Nice, Lee!

Is it in any sort of form where you could share a rough version? I'd be spinning my wheels for a while to try and figure it out.

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #3 on: August 07, 2019, 05:37:12 PM »
In addition to Lee's (usual) great stuff there's also this and this if you wanted to (mostly) "roll yer own". If I had the time or need I'd already have penned such a function. Need may rear it's head soon, who knows. Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Ben Clark

  • Newt
  • Posts: 83
Re: Autolisp to get bitmap pixel values
« Reply #4 on: August 08, 2019, 06:07:13 PM »
Thanks for those links MP. I'll see what I can string together.

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #5 on: August 08, 2019, 09:37:08 PM »
Youíre welcome Ben. Image processing is a cool area. I have done some modest pixel abuse (rotating images etc) thru powershell (generating and invoking a powershell script thru lisp). Iíll rummage thru my code and see if thereís anything useful / shareable.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #6 on: August 08, 2019, 10:40:40 PM »
Try this -- quick and dirty -- not bulletproof yet --

Code: [Select]
(defun _Get_File_Properties_Ex ( file / result shell name_space items item )

    ;;  See original post: http://tinyurl.com/yxa7ngfz
    ;;
    ;;  Get a file's extended properties (Title, Subject, Category ...)
    ;;  returning the result as a list of cons pairs:
    ;;
    ;;      (   ("Name" . "Drawing.dwg")
    ;;          ("Size" . "42 KB")
    ;;          ("Type" . "DWG File")
    ;;          ("Date Modified" . "2011/03/21 10:57 AM")
    ;;          ...
    ;;      )

    (vl-catch-all-apply
        (function
            (lambda ( / folder_name file_name i count )   
                (setq
                    folder_name (vl-filename-directory file)
                    file_name   (strcat (vl-filename-base file) (vl-filename-extension file))
                    shell       (vlax-create-object "Shell.Application")
                    name_space  (vlax-invoke shell 'NameSpace folder_name)
                    items       (vlax-invoke name_space 'Items)
                    item        (vlax-invoke name_space 'ParseName file_name)
                    i           (setq count 300)
                )
                (if item
                    (repeat count
                        (setq result
                            (cons
                                (cons
                                    (vlax-invoke
                                        name_space
                                       'GetDetailsOf
                                        items
                                        (setq i (1- i))
                                    )
                                    (vlax-invoke
                                        name_space
                                       'GetDetailsOf
                                        item
                                        i
                                    )
                                )   
                                result
                            )
                        )
                    )
                )   
            )               
        )       
    )
   
    (vl-catch-all-apply 'vlax-release-object (list item))
    (vl-catch-all-apply 'vlax-release-object (list items))
    (vl-catch-all-apply 'vlax-release-object (list name_space))
    (vl-catch-all-apply 'vlax-release-object (list shell))
   
    (vl-remove-if
        (function (lambda (item) (eq "" (car item))))
        result
    )   
   
)

Code: [Select]
(defun _Get_Image_Dimensions ( file )
    (   (lambda ( props foo bar keys ) (if props (mapcar 'bar keys)))
        (mapcar (function (lambda (p) (cons (strcase (car p)) (cdr p)))) (_Get_File_Properties_Ex file))
        (lambda (p) (cons (car p) (vl-string-subst "" "?" (cdr p))))
        (lambda (key) (foo (assoc key props)))
       '("HEIGHT" "WIDTH")
    )
)

(_Get_Image_Dimensions "H:\\Help\\mbicon.bmp")

(   ("HEIGHT" . "45 pixels")
    ("WIDTH" . "35 pixels")
)


Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

myloveflyer

  • Newt
  • Posts: 135
Re: Autolisp to get bitmap pixel values
« Reply #7 on: August 09, 2019, 04:05:47 AM »
Try this -- quick and dirty -- not bulletproof yet --

Code: [Select]
(defun _Get_File_Properties_Ex ( file / result shell name_space items item )

    ;;  See original post: http://tinyurl.com/yxa7ngfz
    ;;
    ;;  Get a file's extended properties (Title, Subject, Category ...)
    ;;  returning the result as a list of cons pairs:
    ;;
    ;;      (   ("Name" . "Drawing.dwg")
    ;;          ("Size" . "42 KB")
    ;;          ("Type" . "DWG File")
    ;;          ("Date Modified" . "2011/03/21 10:57 AM")
    ;;          ...
    ;;      )

    (vl-catch-all-apply
        (function
            (lambda ( / folder_name file_name i count )   
                (setq
                    folder_name (vl-filename-directory file)
                    file_name   (strcat (vl-filename-base file) (vl-filename-extension file))
                    shell       (vlax-create-object "Shell.Application")
                    name_space  (vlax-invoke shell 'NameSpace folder_name)
                    items       (vlax-invoke name_space 'Items)
                    item        (vlax-invoke name_space 'ParseName file_name)
                    i           (setq count 300)
                )
                (if item
                    (repeat count
                        (setq result
                            (cons
                                (cons
                                    (vlax-invoke
                                        name_space
                                       'GetDetailsOf
                                        items
                                        (setq i (1- i))
                                    )
                                    (vlax-invoke
                                        name_space
                                       'GetDetailsOf
                                        item
                                        i
                                    )
                                )   
                                result
                            )
                        )
                    )
                )   
            )               
        )       
    )
   
    (vl-catch-all-apply 'vlax-release-object (list item))
    (vl-catch-all-apply 'vlax-release-object (list items))
    (vl-catch-all-apply 'vlax-release-object (list name_space))
    (vl-catch-all-apply 'vlax-release-object (list shell))
   
    (vl-remove-if
        (function (lambda (item) (eq "" (car item))))
        result
    )   
   
)

Code: [Select]
(defun _Get_Image_Dimensions ( file )
    (   (lambda ( props foo bar keys ) (if props (mapcar 'bar keys)))
        (mapcar (function (lambda (p) (cons (strcase (car p)) (cdr p)))) (_Get_File_Properties_Ex file))
        (lambda (p) (cons (car p) (vl-string-subst "" "?" (cdr p))))
        (lambda (key) (foo (assoc key props)))
       '("HEIGHT" "WIDTH")
    )
)

(_Get_Image_Dimensions "H:\\Help\\mbicon.bmp")

(   ("HEIGHT" . "45 pixels")
    ("WIDTH" . "35 pixels")
)


Cheers.

MP, win10 CAD2020 test did not return results? :-(
Never give up !

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #8 on: August 09, 2019, 08:49:40 AM »
Sorry, not a lot to go on. Work inside out to determine the location of the failure (assuming you passed the correct path to a bitmap image), starting with the statement (vlax-create-object "Shell.Application").
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

ronjonp

  • Needs a day job
  • Posts: 7060
Re: Autolisp to get bitmap pixel values
« Reply #9 on: August 09, 2019, 09:18:00 AM »
Quick test here and it worked fine:
Quote
_$

_GET_FILE_PROPERTIES_EX
_GET_IMAGE_DIMENSIONS
(("HEIGHT" . "1320 pixels") ("WIDTH" . "1020 pixels"))
; 3 forms loaded from #<editor "<Untitled-2> loading...">
_$

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #10 on: August 09, 2019, 09:20:42 AM »
Thanks for testing RJP. :)
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

ronjonp

  • Needs a day job
  • Posts: 7060
Re: Autolisp to get bitmap pixel values
« Reply #11 on: August 09, 2019, 10:58:37 AM »
Thanks for testing RJP. :)
Anytime :)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Ben Clark

  • Newt
  • Posts: 83
Re: Autolisp to get bitmap pixel values
« Reply #12 on: August 09, 2019, 06:13:10 PM »
Worked for me also

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #13 on: August 09, 2019, 06:36:10 PM »
Cool, thx for letting me know.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

myloveflyer

  • Newt
  • Posts: 135
Re: Autolisp to get bitmap pixel values
« Reply #14 on: August 09, 2019, 09:56:17 PM »
Quick test here and it worked fine:
Quote
_$

_GET_FILE_PROPERTIES_EX
_GET_IMAGE_DIMENSIONS
(("HEIGHT" . "1320 pixels") ("WIDTH" . "1020 pixels"))
; 3 forms loaded from #<editor "<Untitled-2> loading...">
_$
I still tried unsuccessfully, "Parameter type error: (or stringp symbolp): nil"
Never give up !

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #15 on: August 09, 2019, 10:07:16 PM »
Perhaps the keys returned by _Get_File_Properties_Ex are different due to language difference. Can you execute (_Get_File_Properties_Ex full-path-of-file)? If so please post results.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

myloveflyer

  • Newt
  • Posts: 135
Re: Autolisp to get bitmap pixel values
« Reply #16 on: August 10, 2019, 04:37:38 AM »
Perhaps the keys returned by _Get_File_Properties_Ex are different due to language difference. Can you execute (_Get_File_Properties_Ex full-path-of-file)? If so please post results.
OK,Mp!
I will show it to you.
(_Get_File_Properties_Ex "D:\\Test\\Test20.dwg")
(("Name". "Tpst_Bearing_Bolt_M20.dwg") ("Size". "38.4 KB") ("Project Type". "DWG File") ("Modified Date". "2019/4/19 23:08") ("Create Date". "2019/4/18 10:39") ("Access Date". "2019/4/18 11:24") ("Properties" . "A") ("Offline Status"). "") ("Availability". "") ("Assumed Type". "Unspecified") ("Owner". "Administrators") ("Category". "Picture") ("Shooting Date". "" ("Artists participating in the creation". "") ("Album". "") ("Year". "") ("Genre". "") ("Commander". "") ("Mark" "") ("Grade". "Unrated") ("Author". "") ("Title" . "") ("Theme". "") ("Category". "") ("Remarks" "") ("Copyright". "") ("#" . "") ("Time"" "") ("Bit Rate". "") ("Protection". "") ("Camera Model" "") ("Resolution". "") ("Camera Manufacturer". "") ("Company". "") ("File Description". "") ("Host Keyword". "") ("Host Keyword". "") ("Program Name". "") ("Duration". "") ("Online". "") ("Repeat". "") ("Location"." ") ("Optional Participant Address". "") ("Optional Participant". "") ("Organizer "" "") ("Organizer Name". "") ("Reminder Time". "") ("Required Participant Address". "") ("Required Participant". "") ("Resources". "") ("Conference Status". "") ("Busy Status". "") ("Total Size". "155 GB") ("Account Name". "") ("Task Status " . "") ("Computer" . "DESKTOP-OVEVC0R (this computer)") ("Remembrance Day". "") ("Assistant Name". "") ("Assistant Phone". "") ( "Birthday". "") ("Business Address". "") ("Company's City". "") ("Company Country". "") ("Company Mail". "") (" The zip code of the company's location " . "") ("The province where the company is located". "") ("The street address of the company". "") ("Business Fax". "") ("Company Homepage". "" ("Business Phone". "") ("callback number". "") ("Car phone". "") ("Children". "") ("Company main phone". "") ("Department " . "") ("Email address". "") ("Email 2". "") ("Email 3". "") ("E-mail list". "") ("E-mail display The name " . "") ("File is". "") ("Name". "") ("Full name". "") ("Sex". "") ("Name". "") (" personal hobby" . "" ("Residential Address" . "") ("City of the City/County". "") ("Country Country". "") ("Residential Mailbox" . "") ("Post Code " . "") ("The province where the residence is located". "") ("Street address of the residence". "") ("Residential fax". "") ("Home phone". "") ("Import Address " . "") (" initials" . "") ("title". "") ("label". "") ("surname". "") ("address"" "") (" The middle name " . "") ("mobile phone". "") ("nickname". "") ("office location". "") ("Other address". "") ("Other cities and counties". "" ("Other countries/regions" . "") ("Other postal mailboxes". "") ("Other postal codes". "") ("Other provinces and municipalities". "") ("Other street addresses". "") ("pager". "") ("Title". "") ("City". "") ("Country"" "") ("Email". "") ("ZIP " . "") ("Province and Municipality". "") ("Street Address". "") ("Primary Email". "") ("Main Phone". "") ("Professional". "" ("Spouse/Partner". "") ("Suffix". "") ("TTY/TTD Phone". "") ("Telex" . "") ("Web". "") ("Content Status " . "") ("Content class " . "") ("Get Date". "") ("Archive Date". "") ("Completion Date". "") ("Device Category". "") ("Connected". "") ("Discovery Method". "") ("Friendly Name". "") ("Local Computer". "") ("Manufacturer". "") ("Model". "") ("Paired". "") ("Classification". "") ("Status". "") ("Printer Status". "") ("Client ID". "") ("Participant". "") ("Create Content time " . "") ("last printed time". "") ("last saved date". "") ("partition". "") ("document ID". "") ("Page Range". "") ("Slideshow". "") ("Total Editor Time". "") ("Number of Words". "") ("Deadline". "") ("End Date" "") ("File Count". "") ("File Extension". ".dwg") ("Filename". "Tpst_Bearing_Bolt_M20.dwg") ("File Version". "") ("Sign Color " . "") ("Mark Status". "") ("Free Space". "34.1 GB") ("Group". "") ("Share Type". "") ("Bit Depth". "" ("Horizontal Resolution" . "") ("Width". "") ("Vertical Resolution". "") ("Height". "") ("Importance". "") ("Annex " . "") ("Deleted". "") ("Encryption Status " . "") ("有标志". "") ("Completed". "") ("Incomplete". "") ("Reading Status". "") ("Shared". "No" ("Writer". "") ("Date". "") ("Folder Name". "Tpst_Software") ("Folder Path". "D:\\Tpst_Software") ("Folder". "Tpst_Software (D:)") ("Participant". "") ("Path". "D:\\Tpst_Software\\Tpst_Bearing_Bolt_M20.dwg") ("Depending on location". "") ("Type"." DWG file ") ("Contact". "") ("Entry Type". "") ("Language". "") ("Access Time". "") ("Description". "") ("Link Status " . "Unresolved") ("Link Target". "") ("URL" . "") ("Create Media Date". "") ("Publish Date". "") ("Coder". "") ("Number of Sets". "") ("producer". "") ("Publisher". "") ("Quarter". "") ("Subtitle". "") ("User Web URL" . "") ("Creator". "") ("Attachment". "") ("Bcc Address". "") ("Bcc". "") ("Cc Address " . "") ("CC"" "") ("Session ID". "") ("Receive Date". "") ("Send Date". "") ("Sender Address"." ") ("From". "") ("With attachment". "") ("Sender address " . "") ("Sender". "") ("Storage". "") ("Recipient Address". "") ("Operation Title". "") ("Recipient"." ") ("mileage". "") ("Album Artist". "") ("Original by album artist". "") ("Album ID". "") ("Sort by album". "") ("Sort by artists participating in the creation". "") ("Number of beats per minute". "") ("Composer". "") ("Sort by composer". "") ("Disc " . "") ("Initial tonality". "") ("Part of compilation". "") ("Aura". ")) ("Partial settings". "") ("Phase". "") ("Color". "") ("Parent Rating". "") ("Parent Rating Reason". "") ("Used Space". "?77%") ("EXIF Version". "") ("Event". "") ("Exposure Compensation". "") ("Exposure Program". "") ("Exposure Time". "") ("Aperture Value". "") ("Flash Mode". "") ("focal length" . "") ("35mm focal length" . "") ("ISO speed". "") ("Lens manufacturer". "") ("Lens model". "") (" Light source " . "") ("Maximum aperture". "") ("Metering mode". "") ("Direction". "") ("Person"" "") ("Program mode". "") ("Saturation". "") ("Target Distance". "") ("White Balance". "") ("Excellent "" "") ("Project". "") ("Channel Number". "") ("Theatrical Name". "") ("Closed Caption". "") ("Re-run". "") ("SAP" . "") ("Broadcast Date". "") ("Program Description". "") ("When Recording
"" "") ("Radio Call Signal". "") ("Radio Name". "") ("Summary". "") ("Snippet". "") ("Automatic Summary". "") ("Association". "") ("File Ownership". "") ("Sensitivity". "") ("Shared Device". "") ("Shared Status". "Not Shared") ("Product Name " . "") ("product version" . ""))
Never give up !

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #17 on: August 10, 2019, 08:37:13 AM »
Thanks HF. It appears the wasn't copied correctly, the list appears somewhat corrupt (imbalanced parenthesis etc).

Also, please pass the path to an existing bitmap file, not an AutoCAD drawing, e.g.:

(_Get_Image_Dimensions "C:\\Windows\\System32\\OEM\\FabrikamLogo.bmp")

>> (("HEIGHT" . "80 pixels") ("WIDTH" . "145 pixels"))

If the height and width are not returned for a bitmap image then try the _Get_File_Properties_Ex function, making the output easy to read, e.g.

(progn
    (mapcar 'print
        (_Get_File_Properties_Ex "C:\\Windows\\System32\\OEM\\FabrikamLogo.bmp")
    )
    (princ)
)


("Name" . "FabrikamLogo.bmp")
("Size" . "2.38 KB")
("Item type" . "BMP File")
("Date modified" . "2015-08-04 4:30 PM")
("Date created" . "2018-09-27 11:21 AM")
...
("Shared with" . "")
("Sharing status" . "Not shared")
("Product name" . "")
("Product version" . "")
("Support link" . "")


Thank you.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

myloveflyer

  • Newt
  • Posts: 135
Re: Autolisp to get bitmap pixel values
« Reply #18 on: August 11, 2019, 10:23:00 PM »
Thanks HF. It appears the wasn't copied correctly, the list appears somewhat corrupt (imbalanced parenthesis etc).

Also, please pass the path to an existing bitmap file, not an AutoCAD drawing, e.g.:

(_Get_Image_Dimensions "C:\\Windows\\System32\\OEM\\FabrikamLogo.bmp")

>> (("HEIGHT" . "80 pixels") ("WIDTH" . "145 pixels"))

If the height and width are not returned for a bitmap image then try the _Get_File_Properties_Ex function, making the output easy to read, e.g.

(progn
    (mapcar 'print
        (_Get_File_Properties_Ex "C:\\Windows\\System32\\OEM\\FabrikamLogo.bmp")
    )
    (princ)
)


("Name" . "FabrikamLogo.bmp")
("Size" . "2.38 KB")
("Item type" . "BMP File")
("Date modified" . "2015-08-04 4:30 PM")
("Date created" . "2018-09-27 11:21 AM")
...
("Shared with" . "")
("Sharing status" . "Not shared")
("Product name" . "")
("Product version" . "")
("Support link" . "")


Thank you.
Hi,MP.
Code: [Select]
(progn
    (mapcar 'print
        (_Get_File_Properties_Ex "C:\\Windows\\System32\\OEM\\FabrikamLogo.bmp")
    )
    (princ)
)
("name". "1.bmp")
("Size". "22.5 KB")
("Project Type". "BMP File")
("Revised date". "2019/8/9 15:52")
("Create Date". "2019/8/12 10:14")
("Visit Date". "2019/8/12 10:14")
("Properties" . "A")
("Offline Status". "")
("Availability". "")
("Assumed Type". "Image")
("Owner". "Administrators")
("Category". "Picture")
("Shooting Date". "")
("Artists involved in the creation". "")
("Album". "")
("year" . "")
("genre". "")
("Commander". "")
("Mark". "")
("Grade"" "Unrated"
("Author". "")
("Title" . "")
("Theme". "")
("Category". "")
("Remarks". "")
("Copyright". "")
("#" . "")
("duration" . "")
("bit rate". "")
("Protection". "")
("Camera model". "")
("Resolution" . "?203 x 108?")
("Camera Manufacturer". "")
("the company" . "")
("File Description". "")
("Host Keyword". "")
("Host Keyword". "")
("Program Name". "")
("duration" . "")
("Online". "")
("Repeat". "")
("Location". "")
("Optional Participant Address". "")
("Optional Participant". "")
("Organizer Address". "")
("Organizer name". "")
("Reminder time". "")
("Musted Participant Address". "")
("Musted Participants". "")
("Resources". "")
("Conference Status". "")
("Busy status". "")
("Total size". "223 GB")
("account name" . "")
("Task Status". "")
("Computer". "DESKTOP-OVEVC0R (this computer)")
("Remembrance Day". "")
("Assistant Name". "")
("Assistant Phone". "")
("Birthday". "")
("Business Address" . "")
("The city where the company is located". "")
("Company's country". "")
("Company email" . "")
("The zip code of the company's location". "")
("The province where the company is located". "")
("The street address of the company". "")
("Business Fax". "")
("Company's main page" . "")
("Business Phone". "")
("callback number". "")
("Car phone". "")
("Children". "")
("Company's main phone". "")
("Department". "")
("Email address" . "")
("Email 2". "")
("Email 3". "")
("Email List". "")
("Email Display Name". "")
("File is". "")
("first name" . "")
("full name" . "")
("gender". "")
("Name". "")
("personal hobby" . "")
("Residential Address" . "")
("The city/county where the residence is located". "")
("Home country". "")
("Residential Mailbox". "")
("Postal code of the residence location". "")
("The province where the residence is located". "")
("Street address of the residence". "")
("Residential Fax". "")
("residence phone" . "")
("Immediate Address"" "")
(" initials". "")
("Position". "")
("label". "")
("Last name". "")
("mailing address" . "")
("middle name" . "")
("mobile phone". "")
("nickname". "")
("office location". "")
("Other Address". "")
("Other cities and counties". "")
("Other countries". "")
("Other PO Boxes". "")
("Other ZIP Code". "")
("Other provinces and municipalities". "")
("Other Street Addresses". "")
("pager". "")
("title". "")
("City and County". "")
("country / region" . "")
("mailbox". "")
("zip code". "")
("Provinces" . "")
("Street address" . "")
("Primary Email". "")
("Main Phone". "")
("Occupation". "")
("Spouse/Partner". "")
("suffix". "")
("TTY/TTD Phone". "")
("Telex" . "")
("Web page" . "")
("Content Status". "")
("Content Type". "")
("Get Date". "")
("Archive Date". "")
("Date of completion" . "")
("Equipment category" . "")
("connected" . "")
("Discovery Method". "")
("Friendly name". "")
("Local Computer". "")
("manufacturer" . "")
("Model". "")
("paired". "")
("Classification". "")
("Status". "")
("Printer Status". "")
("Client ID". "")
("Participant". "")
("Time to create content". "")
("Time of last print". "")
("The last saved date". "")
("Division". "")
("Document ID". "")
("Page Range". "")
("Slideshow". "")
("Total Editor's Time". "")
("number of words". "")
("deadline" . "")
("end date". "")
("File Count". "")
("file extension". ".bmp")
("file name". "1.bmp")
("file version" . "")
("flag color". "")
("Mark Status". "")
("Free Space". "145 GB")
("Group". "")
("Share Type". "")
("bit depth". "8")
("horizontal resolution". "?96 dpi")
("Width". "?203 pixels")
("Vertical Resolution". "?96 dpi")
("height". "?108 pixels")
("Importance". "")
("is an attachment". "")
("deleted" . "")
("Encryption Status". "")
("There are signs". "")
("completed" . "")
("incomplete" . "")
("Reading Status". "")
("Shared". "No")
("Writer". "")
("Date". "")
("folder name". "0409")
("folder path". "C:\\Windows\\System32\\0409")
("folder". "0409 (C:\\Windows\\System32)")
("participant" . "")
("path". "C:\\Windows\\System32\\0409\\1.bmp")
("Depending on location". "")
("Type". "BMP file")
("Contact". "")
("entry type". "")
("Language". "")
("interview time" . "")
("Description". "")
("link status". "unresolved")
("link target". "")
("URL" . "")
("Create Media Date". "")
("Release date" . "")
("Coders". "")
("Episode" . "")
("Producer" . "")
("announcer" . "")
("Quarter". "")
("Subtitle". "")
("User Web URL" . "")
("Creator" . "")
("Attachment". "")
("Bcc Address". "")
("BCC" . "")
("CC address". "")
("CC". "")
("Session ID". "")
("receiving date". "")
("send date". "")
("Sender Address". "")
("Sender". "")
("with attachment". "")
("Sender address". "")
("Sender". "")
("storage". "")
("receiver's address" . "")
("Operation Title". "")
("Recipient". "")
("mileage". "")
("Album Artist". "")
("Sort by album artist". "")
("Album ID". "")
("Sort by album". "")
("Sort by artists participating in the creation". "")
("Number of beats per minute". "")
("Composer" . "")
("Sort by composer". "")
("CD". "")
("Initial tonality". "")
("Part of compilation". "")
("Aura". "")
("Partial Settings". "")
("Time". "")
("colour" . "")
("Parent Rating". "")
("Parent Rating Reason". "")
("Used space". "?34%")
("EXIF version". "")
("Event". "")
("Exposure Compensation". "")
("Exposure Program". "")
("Exposure time". "")
("Aperture value". "")
("flash mode". "")
("focal length". "")
("35mm focal length" . "")
("ISO Speed". "")
("Lens Manufacturer". "")
("Lens Model". "")
("Light source". "")
("Maximum aperture". "")
("Metering Mode". "")
("direction". "")
("Personnel". "")
("Program mode". "")
("saturation" . "")
("Target distance". "")
("White Balance". "")
("priority" . "")
("Project". "")
("Channel number". "")
("The name of the episode". "")
("Closed Caption". "")
("Rerun". "")
("SAP" . "")
("broadcast date". "")
("Program Description". "")
("recording time". "")
("Radio Call Signal". "")
("Radio name". "")
("Summary" . "")
("Fragment". "")
("Automatic Summary". "")
("association". "")
("File Ownership". "")
("Sensitivity". "")
("Shared Device". "")
("Shared Status". "Not Shared")
("product name" . "")
("product version" . "")
Never give up !

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #19 on: August 11, 2019, 11:17:42 PM »
(_Get_Image_Dimensions "C:\\Windows\\System32\\OEM\\FabrikamLogo.bmp")
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

kozmos

  • Newt
  • Posts: 33
Re: Autolisp to get bitmap pixel values
« Reply #20 on: September 07, 2019, 01:41:49 AM »
you can directly use WIA object to directly access picture properties:

(setq WIA (vlax-get-or-create-object "WIA.ImageFile"))
  (vlax-invoke-method WIA "LoadFile" IMG)
  (list   (vlax-get-property WIA "Width")
   (vlax-get-property WIA "Height")
  )
KozMos Inc.

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #21 on: September 07, 2019, 03:24:59 AM »
Awesome post kozmos - thanks for posting - eager to explore it when Iím at my workstation. More info here for the interested.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17498
Re: Autolisp to get bitmap pixel values
« Reply #22 on: September 09, 2019, 11:32:34 AM »
Cool, works here. Quickly wrapping up as a function ...

Code: [Select]
(defun _Get_Image_Dimensions ( image-path / result )
    (vl-catch-all-apply
       '(lambda ( / wia )
            ;;  if performing this repeatedly consider
            ;;  caching an instance of the wia object
            (vlax-invoke-method
                (setq wia (vlax-get-or-create-object "WIA.ImageFile"))
               'loadfile
                image-path
            )
            (setq result
                (mapcar
                   '(lambda (p) (vlax-get wia p))
                   '(height width)
                )
            )
        )
    )
    result
)

Tx kozmos; cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox