Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Karl Wochele Newsgroups: comp.lang.clipper.visual-objects Subject: Re: Shinking JPEGs Date: Wed, 17 Apr 2013 09:49:49 +0200 Lines: 159 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net BYQ0U6YkSf7qMbAJzS20Nwjv3J/0DkHszjRiwJjyIcUvWy4YDq Cancel-Lock: sha1:AKQEqHohkcuZXq6y60QAwcjHDkg= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: Xref: csiph.com comp.lang.clipper.visual-objects:5071 Hi Kuno, This might help you: http://www.rw-designer.com/photo-resizer-advanced Download Photoresize400.exe, then rename it to Photoresize.exe. It is a command line tool which produces quite good quality. You can use the following VO-Interface: ************** STATIC DEFINE BUFSIZE := 1024 STATIC DEFINE RUN_TIMEOUT := 100 FUNCTION ResizeJpg(cInFile AS STRING,cOutFile AS STRING,nWidth AS DWORD,nHeight AS DWORD) AS VOID PASCAL LOCAL cRet AS STRING LOCAL cCmd AS STRING cCmd := "PhotoResize.exe "+"-h"+NTrim(nHeight)+" -q100 -n -m -o -c"+cOutFile+" "+cInFile RunPiped(cCmd,0,@cRet) RETURN FUNCTION RunPiped(cCmdLine AS STRING,nTimeout := 0 AS DWORD,cRet REF STRING) AS LOGIC LOCAL lOk AS LOGIC LOCAL PipeReadHandle AS PTR LOCAL PipeWriteHandle AS PTR LOCAL StartupInfo IS _WINSTARTUPINFO LOCAL ProcessInfo IS _WINPROCESS_INFORMATION LOCAL SecurityAttributes IS _WINSECURITY_ATTRIBUTES LOCAL nWait AS DWORD LOCAL dwExit AS DWORD LOCAL nRead AS DWORD LOCAL nAvail AS DWORD LOCAL nRest AS DWORD LOCAL pBuff AS PSZ MemSet(@StartupInfo,0,_SIZEOF(_WINSTARTUPINFO)) MemSet(@ProcessInfo,0,_SIZEOF(_WINPROCESS_INFORMATION)) MemSet(@SecurityAttributes,0,_SIZEOF(_WINSECURITY_ATTRIBUTES)) SecurityAttributes.nLength := _SIZEOF(_WINSECURITY_ATTRIBUTES) SecurityAttributes.lpSecurityDescriptor := NULL_PTR SecurityAttributes.bInheritHandle := TRUE BEGIN SEQUENCE IF !CreatePipe(@PipeReadHandle,@PipeWriteHandle,@SecurityAttributes,0) cRet := "Fehler beim Erstellen der Pipe!" BREAK ENDIF StartupInfo.cb := _SIZEOF(_WINSTARTUPINFO) StartupInfo.dwFlags := _OR(STARTF_USESHOWWINDOW,STARTF_USESTDHANDLES) StartupInfo.wShowWindow := SW_HIDE StartupInfo.hStdInput := GetStdHandle(STD_INPUT_HANDLE) StartupInfo.hStdOutput := PipeWriteHandle StartupInfo.hStdError := PipeWriteHandle IF !CreateProcess( NULL_PSZ,; String2Psz(cCmdLine),; NULL,; NULL,; TRUE,; 0,; NULL,; NULL_PSZ,; @StartupInfo,; @ProcessInfo ) cRet := "Fehler beim Starten des Prozesses!" BREAK ENDIF lOk := TRUE IF GetExitCodeProcess(ProcessInfo.hProcess,@dwExit) nWait := 0 WHILE(dwExit=STILL_ACTIVE) nWait += RUN_TIMEOUT IF nWait > nTimeout .AND. nTimeout > 0 TerminateProcess(ProcessInfo.hProcess,5333) lOk := FALSE EXIT ENDIF Sleep(RUN_TIMEOUT) GetExitCodeProcess(ProcessInfo.hProcess,@dwExit) ENDDO ENDIF CloseHandle(PipeWriteHandle) PipeWriteHandle := NULL_PTR cRet := "" WHILE(TRUE) pBuff := MemAlloc(BUFSIZE) PeekNamedPipe( PipeReadHandle,; pBuff,; BUFSIZE,; @nRead,; @nAvail,; @nRest) IF nRead > 0 ReadFile(PipeReadHandle,pBuff,BUFSIZE,@nRead,NULL_PTR) cRet += Psz2String(pBuff) ENDIF MemFree(pBuff) IF nRead = 0 EXIT ENDIF ENDDO CloseHandle(ProcessInfo.hThread) CloseHandle(ProcessInfo.hProcess) lOk := TRUE END SEQUENCE IF PipeReadHandle <> NULL_PTR CloseHandle(PipeReadHandle) ENDIF IF PipeWriteHandle <> NULL_PTR CloseHandle(PipeWriteHandle) ENDIF RETURN lOk ************** HTH Karl Am 03.04.2013 21:21, schrieb Kuno Egger: > I need to reduce the size of jpg photos for upload to a web shop. I am trying to use FabPaint but have not hit on the right way to do it. > > I can use FabPaint to display large jpg photos (see code) but not save them as smaller files. > > Any advice would be greatly appreciated. > > ---------------------------------------------- > > SELF:oDCPict:Image := FabPaintLib{ cFileName } > nWidth := SELF:oDCPict:Image:width > nHeight := SELF:oDCPict:Image:height > IF nWidth > 411 .OR. nHeight > 284 > DO WHILE nWidth > 411 .OR. nHeight > 284 > IF Integer(nWidth * .6) < 411 > nWidth := Integer(nWidth * .99) > nHeight := Integer(nHeight * .99) > ELSE > nWidth := Integer(nWidth * .6) > nHeight := Integer(nHeight * .6) > ENDIF > ENDDO > SELF:oDCPict:Image:ResizeBox( nWidth, nHeight, 1 ) > ENDIF > SELF:oDCPict:show() > >