2 4 Votes

Delphi: Loading JPEG image in TImage does not work: Exception EInvalidGraphic: Unknown picture file extension (.jpg)

Question by Chematik | 13/09/2012 at 11:28

In my program, I want to load a jpg image dynamically and then it should be displayed. For this, I have drawn a TImage Delphi component on the form and use the following code:


Unfortunately, this is not working at all and instead, I get an error with the following error message:

Project Project1.exe raised exception class EInvalidGraphic with
message 'Unknown picture file extension (.jpg)

In other words, Delphi seems to do not understand JPG graphics. But I think: if not JPEG, what then? How can I correct the error?



Show Profile | Message
16Best Answer
22 Votes

Just add "Jpeg" to the USES-list at the top of your code. You have to do that, because otherwise, Delphi can not understand the JPG-format. With this correction, it should work.

After that, above it should look similiar to that:

  Windows, Messages, ... SysUtils, Jpeg;

And you can load JPG images into your TImage.
15/09/2012 at 18:41

ReplyPositive Negative
19 Votes

I will thank you Delphian on behalf of myself and the person who asked it since that person seems to be too lazy lol
04/08/2013 at 00:16

Positive Negative
06 Votes

Thats it. Thanks Delphian.

(Comment to short?? Sorry only wanted to say Thank you Delphian..) Hope this is long enough to say thanks?
09/07/2015 at 13:06

Positive Negative
04 Votes

Hey I'm also stuck in this same situation... I have added Jpeg to uses. But still its giving me the same error. 

This is my code: 


procedure TLoginForm.Button3Click(Sender: TObject);

Can someone help me?
02/03/2016 at 22:20

ReplyPositive Negative
15 Votes

Perhaps you can try to add the complete Vcl.Imaging name space to your project.

Go to: Project > Options > Delphi Compiler > Unit Scope Names Menu.
03/03/2016 at 18:34

Positive Negative
44 Votes

You forget this line before the begin.

Var imguserpic : tjpegImage;

That because it give you an error.
13/05/2017 at 18:09

Positive Negative

Related Topics

WhatsApp: No more Image
Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own articles on askingbox.com. How to do.