<?php
    $size_x = 160;
	$size_y = 160;

    $handle = @opendir( "./" );
    while( $file = readdir( $handle ) )
	{
        if( $file==".." || $file=="." ) continue;

        $file_extension = strtolower( substr( strrchr( $file, "." ), 1 ) );

        if( $file_extension == "jpg" )
        {
        	$to = str_replace( ".jpg", ".gif", $file );
            $to = str_replace( "image", "thumb", $to );

            exec( 'E:\ImageMagick/convert -size '.$size_x.'x'.$size_y.' '.$file.' -resize '.$size_x.'x'.$size_y.' '.$to );
        }
    }
    @closedir( $handle );
?>