Welcome! Log In Create A New Profile

Advanced

[WD] Convert JPEG image quality (and size)

Posted by Gianni Spano 
Gianni Spano
[WD] Convert JPEG image quality (and size)
August 02, 2017 09:30PM
Hello

Starting from an example published on:
[windevapi.free.fr]


I'm trying to reduce the size of images loaded and saved on a longblob field in a table of a MySql database.

This is the portion of code :
PROCEDURE ReduceSize(InFileName, OutFileName, Quality)
wiaFormatJPEG       is string ="B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"


oFichierImage is object Automation dynamic 
oProcessImage is object Automation dynamic 

oFichierImage = new object Automation "WIA.ImageFile" 
oProcessImage = new object Automation "WIA.ImageProcess" 

oFichierImage>>LoadFile(InFileName) 


oProcessImage>>Filters>>Add(oProcessImage>>FilterInfos("Convert")>>FilterID) 
oProcessImage>>Filters(1)>>Properties("FormatID")>>Value = wiaFormatJPEG <<<< The problem is here
oProcessImage>>Filters(1)>>Properties("Quality")>>Value = Quality

oFichierImage = oProcessImage>>Apply(oFichierImage) 
oFichierImage>>SaveFile(OutFileName)

This is the error code i see when the routine is executed:

Error at line 29 of Local Procedure ReduceSize process.
Access to Value Automation member.
Erreur 80210065 : Formato dell'ID non valido.
Erreur 80210065 : Formato dell'ID non valido.

For your info i'm working on a Windows 10 pc..

Please, can someone tell me where is the problem??

Thanks in advance

Gianni



Edited 1 time(s). Last edit at 08/02/2017 10:39PM by Gianni Spano.
Fabrice Harari
Re: [WD] Convert JPEG image quality (and size)
August 03, 2017 01:36PM
Hi Gianni,

I don't know about this example at all, and I don't care to learn, as you can achieve what you want in about 2 lines of wlanguage:

1. Load the image to modify into an image field whose size (..X, ..Y) is your TARGET size
2. Save the image with dsaveImageJPG (it will be at the new size, and with the new resolution that you set in your dsaveimageJPG options)

Done!

Best regards
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: