Change the size of jpg

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Change the size of jpg

Post by franco »

I am wondering if I can change the size of a picture before saving inside hmg.
Because I can not use TESTCAM anymore because of closing of activex I am using Microsoft camera and working good.
My customer has 10 microsoft tablets and the inside webcam only has 1 size setting. It makes 2249 k where the hmg camera makes 201.
Each invoice in the program I made for him uses 24 pictures and when he try`s to email the pdf is to big. Also his hard drive will fill up.
If I reduce thee size of the jpg to 200 to 300k everything would be perfect.
All The Best,
Franco
Canada
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Change the size of jpg

Post by andyglezl »

franco wrote: ↑Thu Jan 21, 2021 3:29 am
I need to take pictures with the camera of a Microsoft go 2 tablet.
The electric motor rewind technicians use the tablets to take pictures of different parts of motors while they rebuild.
They just want to hold tablet and take picture nothing else.
I am waiting for sample picture to post to see if a member (Andy) could show me how to resize with a function inside my program after taking picture.
Franco

Si tienes WORD, puedes crear un documento en blanco y en el insertar tus fotos, das doble click en cada una de ellas y cambias la calidad con las opciones que el WORD te muestra.
Después, guardas ese documento como PDF y lo envías.
*-----------------------------------------------------------------------------------------------------
If you have WORD, you can create a blank document and when you insert your photos, double click on each one and change the quality with the options that the WORD shows you.
Then you save that document as a PDF and send it.

xx.jpg
xx.jpg (171.92 KiB) Viewed 929 times
Andrés González López
Desde Guadalajara, Jalisco. México.
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Change the size of jpg

Post by franco »

Holy Cow and WOW,
Thanks to
Andres, Jimmy an Mol
I have this working in a small program. I have shrunk a 3.2mg picture to 652kb. and it is 100% clear for what I need.
I used Mol`s suggestion designed by Jimmy
Amazing and thanks again.
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Change the size of jpg

Post by franco »

I need to check the size of the jpg file before sizing
This works for large files but small file get distorted.

hBitmap := BT_BitmapCaptureClientArea ("WinCam", 30,250, 360,360 ) //Row, Col, Width, Height)
BT_BitmapSaveFile (hBitmap, wname, .7)
BT_BitmapRelease (hBitmap)

I need to check file size first I do not know how to check jpg size ... like
if wname size > 800 kb
resize
endif
All The Best,
Franco
Canada
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Change the size of jpg

Post by mol »

I'm not sure, which .h files to include, so I've added all

Code: Select all

aSizeOfPicture := HB_GETIMAGESIZE( cFile)

#pragma BEGINDUMP 
#include "HMG_UNICODE.h"
#include "SET_COMPILE_HMG_UNICODE.ch"
#include <hbapi.h> 
#include "hbapifs.h"
#include <winsock2.h> 
#include <iphlpapi.h> 
#include <icmpapi.h> 

#include <windows.h>
#include <commctrl.h>
#include "tchar.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "winreg.h"

#include <wingdi.h>
#include <winuser.h>


HB_FUNC( HB_GETIMAGESIZE )
/*
  Syntax: HB_GETIMAGESIZE( cPicFile )
  Parameter: cPicFile = graphic file (JPG, GIF, PNG)
  Return: 2 dim array -> array[1] = width, array[2] == height
*/
{
   int x = 0, y = 0;

   GetImageSize( hb_parcx( 1 ), &x, &y );

   hb_reta( 2 );
   hb_storvni( x, -1, 1 );
   hb_storvni( y, -1, 2 );
}
	
#pragma ENDDUMP
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Change the size of jpg

Post by mol »

Sorry, I didn't read your request carefully.
You simply want to know size of a file, so use aDir function
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Change the size of jpg

Post by franco »

Thanks Mol,
I think I got it

Code: Select all

	if fileSize(wname)/1000 > 800

 		hBitmap := BT_BitmapCaptureClientArea ("WinCam", 30,250, 360,360 )            //Row, Col, Width, Height)
  		BT_BitmapSaveFile (hBitmap, wname, .7)
   		BT_BitmapRelease (hBitmap)
	endif
All The Best,
Franco
Canada
Post Reply