DynaPDF.ReadImageFormat
-----------------------

The function retrieves the most important properties of an image file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [3.1](newinversion31.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.ReadImageFormat"; PDF; Container { ; Index } ) 

**MBS**( **"DynaPDF.ReadImageFormat";** /\* The function retrieves the most important properties of an image file. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Container**; /\* The image container value. Pass the container field or a variable with the container content.e.g. $image \*/   
**$Index**) /\* Optional; The index of the image for multi image files.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| Container | The image container value. Pass the container field or a variable with the container content. | $image |  |
| Index | The index of the image for multi image files. | 1 | Optional |

### Result

Returns image format or error message.

### Description

The function retrieves the most important properties of an image file.   
The function reads only the image header to improve processing speed. If the parameter BitsPerPixel is 32 the image is a CMYK image. Note that TIFF images support color depths up to 64 bits per pixel. The parameter Index specifies the array index of a multi-page image that should be read in; numbering starts at 1. The parameter is ignored for non-multi-page image formats.  
Image format is returned as a text with width, height and bits per pixel separated by newline.  
See also [ReadImageFormat](https://www.monkeybreadsoftware.com/DynaPDF-Manual/ReadImageFormat.shtml) function in DynaPDF manual.

### Examples

Place an image centered on the page with border:

 Set Variable \[ $r ; Value: MBS ("[DynaPDF.AppendPage](DynaPDFAppendPage.md)"; $pdf ) \]   
\# put a background in   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetFillColor](DynaPDFSetFillColor.md)"; $pdf ; ,8; ,8; ,8) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.Rectangle](DynaPDFRectangle.md)"; $pdf ; 0; 0; MBS ( "[DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md)"; $PDF ); MBS ( "[DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md)"; $PDF ); "fill") \]   
\# options for saving image   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetSaveNewImageFormat](DynaPDFSetSaveNewImageFormat.md)"; $pdf ; 0) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetResolution](DynaPDFSetResolution.md)"; $pdf ; 300) \]   
\# read size of image   
Set Variable \[ $r ; Value: MBS ("DynaPDF.ReadImageFormat"; $pdf ; Merge PDFs::InputImage ) \]   
Set Variable \[ $ImageWidth ; Value: GetAsNumber (LeftValues ( $r ; 1 )) \]   
Set Variable \[ $imageHeight ; Value: GetAsNumber (MiddleValues ( $r ; 2; 1 )) \]   
\# The destination area where to put PDF   
Set Variable \[ $TargetX ; Value: 50 \]   
Set Variable \[ $TargetY ; Value: 50 \]   
Set Variable \[ $TargetWidth ; Value: MBS ( "[DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md)"; $PDF ) - 100 \]   
Set Variable \[ $TargetHeight ; Value: MBS ( "[DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md)"; $PDF ) - 100 \]   
\# calculate scale factor   
Set Variable \[ $factor ; Value: Min( $TargetHeight / $ImageHeight ; $TargetWidth / $ImageWidth ) \]   
\# calculate output size   
Set Variable \[ $DestWidth ; Value: $ImageWidth \* $factor \]   
Set Variable \[ $DestHeight ; Value: $ImageHeight \* $factor \]   
\# Center in target area   
Set Variable \[ $DestX ; Value: $TargetX + ($TargetWidth -$DestWidth ) / 2 \]   
Set Variable \[ $DestY ; Value: $TargetY + ($TargetHeight -$DestHeight ) / 2 \]   
\# insert the image   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.InsertImage](DynaPDFInsertImage.md)"; $pdf ; Merge PDFs::InputImage ; $DestX ; $DestY ; $DestWidth ; $DestHeight ) \]   
\# close page and move to next record   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf ) \]  
### See also

- [DynaPDF.AppendImagePage](DynaPDFAppendImagePage.md)
- [DynaPDF.AppendPage](DynaPDFAppendPage.md)
- [DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md)
- [DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md)
- [DynaPDF.InsertImage](DynaPDFInsertImage.md)
- [DynaPDF.ReadImageFormatFile](DynaPDFReadImageFormatFile.md)
- [DynaPDF.SetFillColor](DynaPDFSetFillColor.md)
- [DynaPDF.SetPageFormat](DynaPDFSetPageFormat.md)
- [DynaPDF.SetResolution](DynaPDFSetResolution.md)
- [DynaPDF.SetSaveNewImageFormat](DynaPDFSetSaveNewImageFormat.md)

### Release notes

- **Version 15.2**
    - Added [DynaPDF.ReadImageFormatFile](https://www.mbsplugins.eu/DynaPDFReadImageFormatFile.shtml) and [DynaPDF.ReadImageResolutionFile](https://www.mbsplugins.eu/DynaPDFReadImageResolutionFile.shtml) function to inspect images files on disk.
- **Version 14.5**
    - Improved [DynaPDF.GeneratePreview](https://www.mbsplugins.eu/DynaPDFGeneratePreview.shtml), [DynaPDF.ReadImageResolution](https://www.mbsplugins.eu/DynaPDFReadImageResolution.shtml), [DynaPDF.ReadImageFormat](https://www.mbsplugins.eu/DynaPDFReadImageFormat.shtml), [DynaPDF.InsertImage](https://www.mbsplugins.eu/DynaPDFInsertImage.shtml), [DynaPDF.AttachFileContainer](https://www.mbsplugins.eu/DynaPDFAttachFileContainer.shtml), [DynaPDF.AddOutputIntentEx](https://www.mbsplugins.eu/DynaPDFAddOutputIntentEx.shtml), [DynaPDF.CreateICCBasedColorSpaceContainer](https://www.mbsplugins.eu/DynaPDFCreateICCBasedColorSpaceContainer.shtml) and [DynaPDF.OpenPDFFromContainer](https://www.mbsplugins.eu/DynaPDFOpenPDFFromContainer.shtml) to return proper error if container is empty.

### Example Databases

- [DynaPDF/Merge PDFs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Merge%20PDFs.shtml#11ScriptAnchor_)
- [DynaPDF/Page Layouting](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Page%20Layouting.shtml#2ScriptAnchor_)
- [DynaPDF/Picture to PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Picture%20to%20PDF.shtml#3ScriptAnchor_)
- [DynaPDF/Place Picture](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Place%20Picture.shtml#1ScriptAnchor_)
- [DynaPDF/Place Template](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Place%20Template.shtml#2ScriptAnchor_)
- [DynaPDF/PSD Conversion](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/PSD%20Conversion.shtml#3ScriptAnchor_)
- [OCR/OCR with DynaPDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/OCR/OCR%20with%20DynaPDF.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.5pr8](https://www.mbsplugins.de/archive/2024-11-08/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Page Layouting in DynaPDF](https://www.mbsplugins.de/archive/2024-04-05/Page_Layouting_in_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [Merge documents with DynaPDF](https://www.mbsplugins.de/archive/2023-07-06/Merge_documents_with_DynaPDF/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 2nd December 2019

  
[DynaPDF.RGB](DynaPDFRGB.md) - [DynaPDF.ReadImageFormatFile](DynaPDFReadImageFormatFile.md)

[HTML Version](DynaPDFReadImageFormat.shtml)