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

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17399
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: 128
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: 17399
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: 128
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: 17399
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: 31
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: 17399
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: 17399
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