# Get Image Resolution

**URL:** <https://clarionhub.com/t/get-image-resolution/5280>\
**Category:** questions\
**Created:** [July 15, 2022, 10:37pm UTC](https://clarionhub.com/t/get-image-resolution/5280 "2022-07-15T22:37:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk2107](https://clarionhub.com/user_avatar/clarionhub.com/sk2107/32/3135_2.png) [@sk2107](https://clarionhub.com/u/sk2107)\
**Post date:** [July 15, 2022, 10:37pm UTC](https://clarionhub.com/t/get-image-resolution/5280/1 "2022-07-15T22:37:43Z")

</div>

Hello everybody,

is there a way to get an image resolution in clarion?  
now I am using vbscript “oImage.HorizontalResolution” as a work around from my clarion application but frankly I am not satisfied with it.

thank you.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [July 15, 2022, 10:59pm UTC](https://clarionhub.com/t/get-image-resolution/5280/2 "2022-07-15T22:59:53Z")

</div>

Are you talking about before you load the image into an image control, or after?

For a Clarion image, you can set PROP:Pixels on the window, create a hidden IMAGE control, set PROP:NoWidth and PROP:NoHeight, load your image file, and read PROP:Height/PROP:Width.

Here’s an example of reading a PNG height/width without loading the entire image.

> **[Basic pre-vetting of a PNG file using StringTheory](https://www.nettalkcentral.com/forum/index.php?topic=8516.0)**
>
> Basic pre-vetting of a PNG file using StringTheory

---

<div class="post-metadata">

**Author:** ![sk2107](https://clarionhub.com/user_avatar/clarionhub.com/sk2107/32/3135_2.png) [@sk2107](https://clarionhub.com/u/sk2107)\
**Post date:** [July 15, 2022, 11:10pm UTC](https://clarionhub.com/t/get-image-resolution/5280/3 "2022-07-15T23:10:22Z")

</div>

thank you for your rapid reply. actually it doesn’t matter if it is after or before as the reason I need this is that I have thousands of images and I want to separate the low resolution images from the other images.

thanks again

---

<div class="post-metadata">

**Author:** ![sk2107](https://clarionhub.com/user_avatar/clarionhub.com/sk2107/32/3135_2.png) [@sk2107](https://clarionhub.com/u/sk2107)\
**Post date:** [July 15, 2022, 11:31pm UTC](https://clarionhub.com/t/get-image-resolution/5280/4 "2022-07-15T23:31:36Z")

</div>

it is ok for width and height but still I cant get the resolution.

any more suggestions is highly appreciated.

regards

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [July 15, 2022, 11:38pm UTC](https://clarionhub.com/t/get-image-resolution/5280/5 "2022-07-15T23:38:06Z")

</div>

Width \* Height = total pixels

---

<div class="post-metadata">

**Author:** ![sk2107](https://clarionhub.com/user_avatar/clarionhub.com/sk2107/32/3135_2.png) [@sk2107](https://clarionhub.com/u/sk2107)\
**Post date:** [July 15, 2022, 11:51pm UTC](https://clarionhub.com/t/get-image-resolution/5280/6 "2022-07-15T23:51:21Z")

</div>

Really sorry I was not clear from the beginning. what I was thinking of resolution in dpi as a result.

---

<div class="post-metadata">

**Author:** ![sk2107](https://clarionhub.com/user_avatar/clarionhub.com/sk2107/32/3135_2.png) [@sk2107](https://clarionhub.com/u/sk2107)\
**Post date:** [July 16, 2022, 6:01pm UTC](https://clarionhub.com/t/get-image-resolution/5280/7 "2022-07-16T18:01:51Z")

</div>

Thank you for your help.

Regards

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [July 16, 2022, 6:39pm UTC](https://clarionhub.com/t/get-image-resolution/5280/8 "2022-07-16T18:39:40Z")

</div>

Pretty sure that most raster images probably don’t have a dpi/ppi (or whatever unit of measure) stored in it. PNG has an optional place to store that. The more dots, the more resolution. The number of those dots that you fit into an inch, cm, etc, is your DPI/PPI/PPC/WTH.  
I envision a DPI in a PNG would be more like a suggestion/default. But if you scale the image to different dimensions on its canvas, now your DPI is different. There’s an x-axis value and y-axis value. I don’t think they are required to be equal.  
DPI/PPI is important during the process of acquiring via a scanner or preparing for print or within photoshop or something.

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [July 17, 2022, 9:29am UTC](https://clarionhub.com/t/get-image-resolution/5280/9 "2022-07-17T09:29:36Z")

</div>

Another way to obtain image resolution without loading the entire image is GdiPlus api: [mikeduglas/GdiPlus: GdiPlus support (github.com)](https://github.com/mikeduglas/GdiPlus)

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [July 17, 2022, 1:47pm UTC](https://clarionhub.com/t/get-image-resolution/5280/10 "2022-07-17T13:47:27Z")

</div>

Neat-o. Is there a list of what kind of images are supported or not supported?

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [July 17, 2022, 2:30pm UTC](https://clarionhub.com/t/get-image-resolution/5280/11 "2022-07-17T14:30:11Z")

</div>

I believe there is 🙂

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [July 17, 2022, 3:00pm UTC](https://clarionhub.com/t/get-image-resolution/5280/12 "2022-07-17T15:00:06Z")

</div>

I really appreciate your neat example, but I’m a little confused.

Does LoadImageFromFile not read the entire image into memory?

That’s the thing I’m trying to avoid, for my purposes. e.g., if someone uploads a huge image to my server, I want to determine first whether it will fit within the limits of the my apps specification before attempting to load it. That’s why my example just reads xx bytes of a PNG to examine the header.

Thanks again Mike

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [July 17, 2022, 3:32pm UTC](https://clarionhub.com/t/get-image-resolution/5280/13 "2022-07-17T15:32:25Z")

</div>

Oh sorry Jeff, LoadImageFromFile definitely does load the entire image, what I meant it is not required to load it into an Image control. GdiPlus has the ability to read image metadata (supported formats are TIFF, JPEG, Exif, and PNG), I will try to implement this feature.

---

<div class="post-metadata">

**Author:** ![MarkGoldberg](https://clarionhub.com/user_avatar/clarionhub.com/markgoldberg/32/1511_2.png) [@MarkGoldberg](https://clarionhub.com/u/MarkGoldberg)\
**Post date:** [July 17, 2022, 3:52pm UTC](https://clarionhub.com/t/get-image-resolution/5280/14 "2022-07-17T15:52:10Z")

</div>

> [@sk2107](#):
>
> I was thinking of resolution in dpi as a result.

You can use ClarionFreeImage - FreeImageClass.iImage.GetDotsPerMeterX

[Clarion FreeImage Project - Download](http://www.clarionfreeimage.com/download.html)

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [July 17, 2022, 4:16pm UTC](https://clarionhub.com/t/get-image-resolution/5280/15 "2022-07-17T16:16:28Z")

</div>

Well in GdiPlus you first load the image, then read metadata.

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [July 18, 2022, 4:59pm UTC](https://clarionhub.com/t/get-image-resolution/5280/16 "2022-07-18T16:59:04Z")

</div>

GdiPlus can return dpi values, now my example shows it:

```
Image c:\Clarion\Clarion11.1\Images\cwwall.bmp, resolution in pixels 168x180, dpi 72
Image c:\Clarion\Clarion11.1\Images\softvelocity.gif, resolution in pixels 150x84, dpi 96
Image c:\Clarion\Clarion11.1\Images\DISKCOPY.ICO, resolution in pixels 32x32, dpi 96
Image c:\Clarion\Clarion11.1\Images\sv_small.jpg, resolution in pixels 110x60, dpi 72
Image c:\Clarion\Clarion11.1\Images\AnyScreen.png, resolution in pixels 333x319, dpi 150

```

---

<div class="post-metadata">

**Author:** ![sk2107](https://clarionhub.com/user_avatar/clarionhub.com/sk2107/32/3135_2.png) [@sk2107](https://clarionhub.com/u/sk2107)\
**Post date:** [July 19, 2022, 8:40am UTC](https://clarionhub.com/t/get-image-resolution/5280/17 "2022-07-19T08:40:59Z")

</div>

> [@Mike\_Duglas](#):
>
> Another way to obtain image resolution without loading the entire image is GdiPlus api: [mikeduglas/GdiPlus: GdiPlus support (github.com)](https://github.com/mikeduglas/GdiPlus)

I will check it. thanks

---

<div class="post-metadata">

**Author:** ![sk2107](https://clarionhub.com/user_avatar/clarionhub.com/sk2107/32/3135_2.png) [@sk2107](https://clarionhub.com/u/sk2107)\
**Post date:** [July 19, 2022, 8:42am UTC](https://clarionhub.com/t/get-image-resolution/5280/18 "2022-07-19T08:42:58Z")

</div>

> [@MarkGoldberg](#):
>
> ou can use ClarionFreeImage - FreeImageClass.iImage.GetDotsPerMeterX
> 
> [Clarion FreeImage Project - Download](http://www.clarionfreeimage.com/download.html)

I already have it but I gave a quick look and did not find how to get the resolution. I will check again more deeper.  
thanks

---

<div class="post-metadata">

**Author:** ![sk2107](https://clarionhub.com/user_avatar/clarionhub.com/sk2107/32/3135_2.png) [@sk2107](https://clarionhub.com/u/sk2107)\
**Post date:** [July 19, 2022, 9:06am UTC](https://clarionhub.com/t/get-image-resolution/5280/19 "2022-07-19T09:06:05Z")

</div>

> [@Mike\_Duglas](#):
>
> Another way to obtain image resolution without loading the entire image is GdiPlus api: [mikeduglas/GdiPlus: GdiPlus support (github.com)](https://github.com/mikeduglas/GdiPlus)

Hi,  
I tried to run it in C6 by recreating the project but I got an error ‘winapi.inc not found’.  
and I tried to open it with C9 but I get the error ''Cannot read Microsoft solution file format 12.00.

thank you

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [July 19, 2022, 9:41am UTC](https://clarionhub.com/t/get-image-resolution/5280/20 "2022-07-19T09:41:07Z")

</div>

[winapi](https://github.com/mikeduglas/winapi) is here.  
Don’t open C11 project in C9, just create new one.

[Next page](https://clarionhub.com/t/get-image-resolution/5280.md?page=2)
