CreateThumbSquare_IrfanView

Creates square thumb for an image, regardless of image aspect ratio
It will always create the square from the middle using width or height whichever lowest
Then resize it and cut the square in the center of image
Does not return anything, just execute the command using Shell

Similar to CreateThumb_IrfanView but this one always creates square thumb from any dimensions images.
Uses IrfanView crop as in ...
    '    /crop=(x,y,w,h)
    '    /crop=(200,100,400,400)

CodeFunctionName
What is this?

Public

Not Tested

Original Work
Function CreateThumbSquare_IrfanView(ImageFile, Optional Wi=200, Optional He=200, Optional IVFol = "Resources")
    ' Creates square thumb for an image, regardless of image aspect ratio
    '    It will always create the square from the middle using width or height whichever lowest
    '    Then resize it and cut the square in the center of image
    '
    ' if the original image is 800x600 pixels and you want to crop a 400x400 square from the center, you can use the following formula:
    ' x = (800 - 400) / 2 = 200
    ' y = (600 - 400) / 2 = 100
    '    /crop=(x,y,w,h)
    '    /crop=(200,100,400,400)
    '    i_view32.exe photos\*.jpg /crop=(200,100,400,400) /resize=(100,100) /aspectratio /resample /convert=thumbnails\*.png
    '
    ' needs FixPath and ImgDimensions which needs ReadFileBytes, L_R256 and R_L256
    '
    ThumImg = GetSon(imageFile) & "_th." & Right(ImageFile, 3)
    Cmd1 = FixPath(FixPath() & IVFol) & "i_view32.exe "
    MyW = 0
    MyH = 0
    MyDims = ImgDimensions(imageFile, MyW, MyH, imgDepth, imgType)
    If MyDims And MyW > 0 and MyH > 0 Then
        NewW = (MyW - Wi) / 2
        NewH = (MyH - He) / 2
       
        Cmd2 = ImageFile
        Cmd3 = " /crop=(" & NewW & "," & NewH & "," & Wi & "," & He & ") /aspectratio /convert="
        Cmd4 = FixPath(GetPapa(ImageFile)) & ThumImg
        Shell Cmd1 & Cmd2 & Cmd3 & Cmd4
    End If
    DoEvents
End Function

ImageFile, Optional Wi=200, Optional He=200, Optional IVFol = "Resources"

Views 157

Downloads 53

CodeID
DB ID