Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #5010 > unrolled thread
| Started by | Kuno Egger <kuno@retailsoftware.com> |
|---|---|
| First post | 2013-04-03 12:21 -0700 |
| Last post | 2013-04-17 09:49 +0200 |
| Articles | 12 — 7 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
Shinking JPEGs Kuno Egger <kuno@retailsoftware.com> - 2013-04-03 12:21 -0700
Re: Shinking JPEGs "Jamal" <jamal@examples.net> - 2013-04-03 16:48 -0400
Re: Shinking JPEGs Fabrice Foray <fabrice.foray@gmail.com> - 2013-04-03 13:53 -0700
Re: Shinking JPEGs Kuno Egger <kuno@retailsoftware.com> - 2013-04-04 10:04 -0700
Re: Shinking JPEGs Fabrice Foray <fabrice.foray@gmail.com> - 2013-04-04 13:50 -0700
Re: Shinking JPEGs Kuno Egger <kuno@retailsoftware.com> - 2013-04-04 15:10 -0700
Re: Shinking JPEGs Paulo Oliveira <paulo@clipinfor.com> - 2013-04-05 02:29 -0700
Re: Shinking JPEGs Fabrice Foray <fabrice.foray@gmail.com> - 2013-04-06 02:28 -0700
Re: Shinking JPEGs "Wolfgang Riedmann" <wriedmann@gmail.com> - 2013-04-04 07:36 +0200
Re: Shinking JPEGs Sherlock <sherlock@sherlock.com.au> - 2013-04-04 08:11 -0700
Re: Shinking JPEGs Kuno Egger <kuno@retailsoftware.com> - 2013-04-04 10:08 -0700
Re: Shinking JPEGs Karl Wochele <kw@e©os-system.de> - 2013-04-17 09:49 +0200
| From | Kuno Egger <kuno@retailsoftware.com> |
|---|---|
| Date | 2013-04-03 12:21 -0700 |
| Subject | Shinking JPEGs |
| Message-ID | <f55b1bdf-9f72-42f0-988e-8e1f41519d13@googlegroups.com> |
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()
[toc] | [next] | [standalone]
| From | "Jamal" <jamal@examples.net> |
|---|---|
| Date | 2013-04-03 16:48 -0400 |
| Message-ID | <kji4i8$d9m$1@speranza.aioe.org> |
| In reply to | #5010 |
Untested code:
After SELF:oDCPict:Image:ResizeBox( nWidth, nHeight, 1 )
add:
SELF:oDCPict:Image:SaveAsJPEG( cFileName )
HTH,
Jamal
"Kuno Egger" wrote in message
news:f55b1bdf-9f72-42f0-988e-8e1f41519d13@googlegroups.com...
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()
[toc] | [prev] | [next] | [standalone]
| From | Fabrice Foray <fabrice.foray@gmail.com> |
|---|---|
| Date | 2013-04-03 13:53 -0700 |
| Message-ID | <e4db51d7-2d5b-4e67-a695-82348ec05da7@googlegroups.com> |
| In reply to | #5010 |
Hi Kuno, what are you trying to achieve ? ResizeBox will resize the image in memory, but you may need to use SaveAs if you want to make the change permanent.... HTH, Fabrice
[toc] | [prev] | [next] | [standalone]
| From | Kuno Egger <kuno@retailsoftware.com> |
|---|---|
| Date | 2013-04-04 10:04 -0700 |
| Message-ID | <4f1805d7-0dbd-4d74-8487-3cfc42631711@googlegroups.com> |
| In reply to | #5012 |
Hi Fabrice, Users have suggested I try: SELF:oDCPict:Image:SaveAsJPEG( cFileName ) I missed it because I couldn't find a list of methods included in your library. Can you tell me where to find it? Thanks Kuno On Wednesday, 3 April 2013 13:53:49 UTC-7, Fabrice Foray wrote: > Hi Kuno, > > what are you trying to achieve ? > > > > ResizeBox will resize the image in memory, but you may need to use SaveAs if you want to make the change permanent.... > > > > HTH, > > Fabrice
[toc] | [prev] | [next] | [standalone]
| From | Fabrice Foray <fabrice.foray@gmail.com> |
|---|---|
| Date | 2013-04-04 13:50 -0700 |
| Message-ID | <ea00abfe-7b4e-48d1-ade7-af0a52e6cee9@googlegroups.com> |
| In reply to | #5016 |
Hi Kuno, I've just uploaded to my homepage, the help file in Chm format : http://www.fabtoys.net/downloads/cat_view/18-visual-objects You can generate the help file by yourself using AutoDoc, also in the Download area. HTH, Fabrice Le jeudi 4 avril 2013 19:04:45 UTC+2, Kuno Egger a écrit : > Hi Fabrice, > > > > Users have suggested I try: > > > > SELF:oDCPict:Image:SaveAsJPEG( cFileName ) > > > > I missed it because I couldn't find a list of methods included in your library. Can you tell me where to find it? > > > > Thanks > > > > Kuno > > > > On Wednesday, 3 April 2013 13:53:49 UTC-7, Fabrice Foray wrote: > > > Hi Kuno, > > > > > > what are you trying to achieve ? > > > > > > > > > > > > ResizeBox will resize the image in memory, but you may need to use SaveAs if you want to make the change permanent.... > > > > > > > > > > > > HTH, > > > > > > Fabrice
[toc] | [prev] | [next] | [standalone]
| From | Kuno Egger <kuno@retailsoftware.com> |
|---|---|
| Date | 2013-04-04 15:10 -0700 |
| Message-ID | <e8329bd2-d543-4c2f-b9aa-17538f32abc7@googlegroups.com> |
| In reply to | #5019 |
Fabrice - Great to see a help file available. Thanks. I downloaded the chm file from your web page. When I open FabPaintLib.chm I only see "Navigation to the web page cancelled..." Do I need to do something after I download it? Kuno
[toc] | [prev] | [next] | [standalone]
| From | Paulo Oliveira <paulo@clipinfor.com> |
|---|---|
| Date | 2013-04-05 02:29 -0700 |
| Message-ID | <abd55b23-cd4d-41a8-9d92-d080ee8fce75@googlegroups.com> |
| In reply to | #5020 |
Hi Kuno,
Basically it is only necessary:
FUNCTION CreateThumbnail2Folder(cJpg,cDest,x,y)
LOCAL oFS AS FileSpec
LOCAL oFab AS FabPaintLib
oFab:=FabPaintLib{}
oFS:=FileSpec{cJpg}
IF oFab:CreateFromFile(cJpg)
oFab:ResizeBilinear(x,y)
oFab:SaveAsJPEG(cDest+"\"+oFS:FileName+oFS:Extension)
ENDIF
I save my thumbnail in a different folder,
Paulo Oliveira
[toc] | [prev] | [next] | [standalone]
| From | Fabrice Foray <fabrice.foray@gmail.com> |
|---|---|
| Date | 2013-04-06 02:28 -0700 |
| Message-ID | <7ff6fbe8-2c0e-4e32-83a5-e74e46e1d287@googlegroups.com> |
| In reply to | #5020 |
Kuno, strange it works ok here... ??? May be due to the version that comes with the help compiler... Anyway, I've uploaded to my homepage the same Help file, but in "pure" HTML format. Download the zip file, and extract all the HTM files in a folder. Double click on Index.htm or Contents.htm, and it should be ok. Regards, Fabrice. Le vendredi 5 avril 2013 00:10:05 UTC+2, Kuno Egger a écrit : > Fabrice - > > > > Great to see a help file available. Thanks. > > > > I downloaded the chm file from your web page. When I open FabPaintLib.chm I only see "Navigation to the web page cancelled..." > > > > Do I need to do something after I download it? > > > > Kuno
[toc] | [prev] | [next] | [standalone]
| From | "Wolfgang Riedmann" <wriedmann@gmail.com> |
|---|---|
| Date | 2013-04-04 07:36 +0200 |
| Message-ID | <as4hqpF6417U1@mid.individual.net> |
| In reply to | #5010 |
Hi Kuno, > 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. for these purposes I'm using the GD lib. You can find a sample here (prepared for an italian user group meeting): http://www.riedmann.it/meeting2009/GD_Demo.zip HTH Wolfgang --
[toc] | [prev] | [next] | [standalone]
| From | Sherlock <sherlock@sherlock.com.au> |
|---|---|
| Date | 2013-04-04 08:11 -0700 |
| Message-ID | <a319055d-35f6-47cb-82e3-69b32f4c5b60@googlegroups.com> |
| In reply to | #5010 |
CLASS bDIBImage
//p Image Manipulation
//d This class encapsulate all services of the FabPaint Library
--------------
LOCAL newZ, shrFactor AS REAL8
LOCAL x, y, z AS LONGINT
LOCAL oImage AS bDIBImage
oImage := bDIBImage{ofspImage:FullPath}
//
IF oImage:IsValid()
z := Max(oImage:Height, oImage:Width)
//
IF z > 800
// I don't think we should expand smaller photos
newZ := REAL8(z)
shrFactor := 800.0 / newZ
newZ := newZ * shrFactor
//
IF z = oImage:Width
x := LONGINT(newZ)
newZ := REAL8(oImage:Height) * shrFactor
y := LONGINT(newZ)
ELSE
y := LONGINT(newZ)
newZ := REAL8(oImage:Width) * shrFactor
x := LONGINT(newZ)
ENDIF
//
oImage:ResizeBilinear(x, y)
//
IF oImage:IsValid()
oImage:SaveAsJPEG( SELF:cImagePath + cNewname )
ENDIF
[toc] | [prev] | [next] | [standalone]
| From | Kuno Egger <kuno@retailsoftware.com> |
|---|---|
| Date | 2013-04-04 10:08 -0700 |
| Message-ID | <c898301c-7104-4b46-98f4-747f08fe741f@googlegroups.com> |
| In reply to | #5015 |
Sherlock, Thanks for the coding lesson! Much appreciated. Kuno
[toc] | [prev] | [next] | [standalone]
| From | Karl Wochele <kw@e©os-system.de> |
|---|---|
| Date | 2013-04-17 09:49 +0200 |
| Message-ID | <at72gtFs5c3U2@mid.individual.net> |
| In reply to | #5010 |
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()
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web