Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Wscript
Message
From
23/07/2018 06:27:53
 
 
To
23/07/2018 06:07:42
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows Server 2012 R2
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01661319
Message ID:
01661320
Views:
77
Likes (1)
The very best way to resize image files, is to use GDIPlusX which is optimized to work with VFP9. Using this library, I have used this generic code for ages:
*ImgResize.prg
Lparameters pcFromFile, pcToFile, plHQ, pnWidth, pnHeight
Do Case 
   Case Type('pcFromFile')#'C'
   Case !Empty(Justext(pcFromFile))
   Case Adir(temp,pcFromFile)=0
   Otherwise 
      Return -1
Endcase 
Local lcType, lnWidth, lnHeight, loZ, lnRatio, lnMaxWidth, lnMaxHeight, loSrcImage, loResized,; 
   loGfx, loType, lnReturn, lcTempfile, lnReturn
lnReturn=0
If Type('pnHeight')='N'
   lnMaxHeight=pnHeight
Else    
   lnMaxHeight=600
Endif      
If Type('pnWidth')='N'
   lnMaxWidth=pnWidth
Else    
   lnMaxWidth=800
Endif      
If Type('pcToFile')#'C' 
   pcToFile = pcFromFile
Endif 
If Empty(Justext(pcToFile))
   pcTofile=Forceext(pcTofile,Justext(pcFromfile))
Endif    
If !type('_screen.system')='O'
   Do prog\gdiplusx\app\system.app && You may have to change this line!
Endif    
lcType=Upper(Justext(pcToFile))
If Lower(pcFromFile)==Lower(pcToFile)
   lcTempfile=Sys(2023)+'\'+Sys(3)+'.'+lcType
   Copy File (pcFromFile) To (lcTempfile)
   Erase (pcFromFile)
   pcFromFile = lcTempfile
Endif    
If plHQ
*   Wait 'HQ' Window Timeout 2
   With _screen.system.Drawing 
      loSrcImage = .Bitmap.New(pcFromFile)
      lnWidth=loSrcImage.width
      lnHeight=loSrcImage.height
      lnRatio = Min(lnMaxHeight/lnHeight, lnMaxWidth/lnWidth)
      lnWidth=lnWidth*lnRatio
      lnHeight = lnHeight*lnRatio
      loResized = .Bitmap.New(lnWidth, lnHeight,.Imaging.PixelFormat.Format32bppARGB)
      loResized.SetResolution(loSrcImage.HorizontalResolution, loSrcImage.VerticalResolution)
      loGfx = .Graphics.FromImage(loResized)
      loGfx.SmoothingMode = .Drawing2D.SmoothingMode.HighQuality
      loGfx.InterpolationMode = .Drawing2D.InterpolationMode.HighQualityBicubic
      loGfx.DrawImage(loSrcImage, 0, 0, lnWIdth, lnHeight)
      Do Case 
         Case lcType='TIF'
            loType='.Imaging.ImageFormat.Tiff'
         Case lcType='JPG'
            loType='.Imaging.ImageFormat.Jpeg'
         Case lcType='PNG'
            loType='.Imaging.ImageFormat.Png'
         Case lcType='GIF'
            loType='.Imaging.ImageFormat.Gif'
         Case lcType='BMP'
            loType='.Imaging.ImageFormat.Bmp'
      Endcase    
      loResized.Save(pcToFile, &loType) 
   Endwith 
Else 
   With _screen.system.Drawing 
      * Load the original Image
      loSrcImage = .Bitmap.New(pcFromFile)
      lnWidth=loSrcImage.width
      lnHeight=loSrcImage.height
      lnRatio = Min(lnMaxHeight/lnHeight, lnMaxWidth/lnWidth)
      lnWidth=lnWidth*lnRatio
      lnHeight = lnHeight*lnRatio
      loResized = loSrcImage.GetThumbnailImage(lnWidth, lnHeight)
      Do Case 
         Case lcType='TIF'
            loType='.Imaging.ImageFormat.Tiff'
         Case lcType='JPG'
            loType='.Imaging.ImageFormat.Jpeg'
         Case lcType='PNG'
            loType='.Imaging.ImageFormat.Png'
         Case lcType='GIF'
            loType='.Imaging.ImageFormat.Gif'
         Case lcType='BMP'
            loType='.Imaging.ImageFormat.Bmp'
      Endcase    
      loResized.Save(pcToFile, &loType) 
   Endwith 
Endif
loSrcImage =.null.
Release loSrcImage 
loResized=.null.
Release loResized
If !Empty(lcTempfile)
   Erase (lcTempfile)
Endif    
If lnReturn=0 And Adir(temp,pcToFile)>0
   lnReturn=temp(1,2)
Endif 
Return lnReturn
>Hello comunity,
>
>I try to create a prg using wscript.shell to resize image from original path to another path an file name:
>my code are:
>
>
>Local ox
>Local LcOriFile as String
>Select ST
>LcOriFile = Alltrim(JustStem(st.imagem))
>LcExtFile = JustExt(st.imagem)
>
>oX=CreateObject("wscript.shell")
>oX.run("C:\Users\Luis Santos\Downloads\ImageMagick-7.0.8-7-portable-Q16-x86\magick convert" , "C:\Users\Luis Santos\Pictures\" + LcOriFile + "." + "lxExtFile  ;
>-resize 10% " , "C:\Users\Luis Santos\Pictures\" + LcOriFile + "_ZIP." + " LcExtFile " , 4, .T.)
>
>
>but when i running my prg this error occur:
>Code: 1426
>Line: 13
>Message1: OLE error code 0x8002000e: Invalid number of parameter.
>
>could someone give me help.
>May thanks,
>Best regards
>Ls
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform