Jump to content

Convert Images Size And Upload


Recommended Posts

  • Moderators

Hi i want to convert all images in a Folder to the propotional size 800x??? an after the convert i wanted to upload the converted Files via FTP to my homepage. Has anyone an Idea for this Script?

Thx for Help

First I'd download and install Irfanview which is a great freeware graphics program. Then use it's command line options to run a batch job to convert your images. Then use the FTP UDF to upload them.
Link to comment
Share on other sites

This is the ready Script.

#include <File.au3>
#include <FTP.au3>
#include <file.au3>

$server = 'server'
$username = 'user'
$pass = 'pass'

$images     = @ScriptDir&"\images\"
$dir        = @ScriptDir&"\images\800\"
$filenames  = @ScriptDir&"\images\*.jpg"
$search     = FileFindFirstFile($filenames) 
$tool       = @ScriptDir & "\i_view32.exe"

Run(@ScriptDir & "\i_view32.exe " & $images & "*.jpg /resample=(800,600) /aspectratio /convert="& $dir &"*.jpg","", @SW_MINIMIZE)

$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $Ftpp = _FtpPutFile($Conn, $dir & $file, '/' & $file)
WEnd

FileDelete($dir&"*.jpg")
MsgBox(0, "Hinweis", 'Fertig')
$Ftpc = _FTPClose($Open)
FileClose($search)

But now i want to convert the filename of the destination file.

i need a way to convert the follow letters to the specified letters

' to _

Uppercase letters to lowercase

space to _

Edited by quicksilver
Link to comment
Share on other sites

$var = "ThIS iS a TesT' lOOk At m'E"
MsgBox(0,"String Manipulation Example", StringLower(StringReplace(StringReplace($var," ", "_"), "'", "_")))

Edited by Simucal
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

$var = "ThIS iS a TesT' lOOk At m'E"
MsgBox(0,"String Manipulation Example", StringLower(StringReplace(StringReplace($var," ", "_"), "'", "_")))

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $filenew = $file
    StringLower(StringReplace($filenew," ", "_"))
    $Ftpp = _FtpPutFile($Conn, $dir & $file, '/' & $filenew)
WEnd

is it wrong? it doesnt work :think:

Link to comment
Share on other sites

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $filenew = $file
    StringLower(StringReplace($filenew," ", "_"))
    $Ftpp = _FtpPutFile($Conn, $dir & $file, '/' & $filenew)
WEnd

StringLower(StringReplace($filenew," ", "_")) is just sitting there byitself. You have to store the result to a variable.

e.g.

$filenew = StringLower(StringReplace($filenew," ", "_"))
Edited by Simucal
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

Yet another fix, instead of:

Run(@ScriptDir & "\i_view32.exe " & $images & "*.jpg /resample=(800,600) /aspectratio /convert="& $dir &"*.jpg","", @SW_MINIMIZE)

use this:

RunWait(@ScriptDir & "\i_view32.exe " & $images & "*.jpg /resample=(800,600) /aspectratio /convert="& $dir &"*.jpg","", @SW_HIDE)

so

Run --> RunWait

@SW_MINIMIZE --> @SW_HIDE

Link to comment
Share on other sites

Next bug:

If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

must be immediatelly after

$search     = FileFindFirstFile($filenames)

because in this case you don't need to create dir, convert images, open FTP and then exit (without closing FTP!).

Link to comment
Share on other sites

i want to add a dropdown field in the tool to switch between different directories..

I want to specifie 3 directories in the tool and want to switch it with a dropdown before i upload the files!

Is it easy? Or a hard way to create?

Edited by quicksilver
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...