tell application "Finder"
  
    set mondossier to (path to desktop folder as text) & "temp:"
    set mondossier to mondossier as alias
    set monfichier to files of mondossier as alias
  
    set nom to name of monfichier
    set AppleScript's text item delimiters to {"."} --récupère la partie avant le dernier "."
    set elements to text items of nom
    set nomcourt to (items 1 thru -2 of elements) as string
    set ancien_nom to nomcourt
    set chemin to the container of monfichier as string
    set nouveau to nomcourt & ".JPEG"
    set enrg to chemin & nouveau as string
    set chemin to the container of monfichier as string
    set nouveau to nomcourt & ".JPEG"
end tell
set thePath to chemin & nouveau
set thePath to POSIX path of thePath
my padBottomOfImageAt:(thePath) byPoints:100
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions
on padBottomOfImageAt:POSIXPath byPoints:padDepth
    -- build path for new file
    set anNSString to current application's NSString's stringWithString:POSIXPath
    set newPath to anNSString's stringByDeletingPathExtension()
    set theExt to anNSString's pathExtension() as text
    set newPath to (newPath's stringByAppendingString:"-2")'s stringByAppendingPathExtension:theExt
    -- load image as bitmap and get its size
    set oldRep to current application's NSBitmapImageRep's imageRepWithContentsOfFile:POSIXPath
    set {width:theWidth, height:theHeight} to oldRep's |size|()
    set newHeight to theHeight + padDepth
    -- make new bitmapImageRep
    set newRep to (current application's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:theWidth pixelsHigh:newHeight bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(current application's NSCalibratedRGBColorSpace) bitmapFormat:(current application's NSAlphaFirstBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
    -- store the existing graphics context
    current application's NSGraphicsContext's saveGraphicsState()
    -- set graphics context to new context based on the new bitmapImageRep
    (current application's NSGraphicsContext's setCurrentContext:(current application's NSGraphicsContext's graphicsContextWithBitmapImageRep:newRep))
    -- set the color to black
    current application's NSColor's blackColor()'s |set|()
    -- fill the bottom area with black
    current application's NSRectFill({origin:{x:0, y:0}, |size|:{width:theWidth, height:padDepth}})
    -- draw from the original bitmapImageRep to the new one above the black area
  
    tell application "Finder"
        activate
        display dialog "Entrer la dimension a couper en bas (en milimètres)" default answer "27"
        set bas to text returned of result
        display dialog "Entrer la dimension a couper en haut (en milimètres)" default answer "0"
        set haut to text returned of result
        display dialog "Entrer la dimension a couper à gauche (en milimètres)" default answer "0"
        set gauche to text returned of result
        display dialog "Entrer la dimension a couper à droite (en milimètres)" default answer "114"
        set droite to text returned of result
        if theWidth < theHeight then
            set H to 210
            set V to 297
        else
            set H to 297
            set V to 210
        end if
    end tell
  
    set OX to theWidth / H * gauche
    set OY to theHeight / V * bas
    set SX to theWidth / H * (H - droite - gauche)
    set SY to theHeight / V * (V - haut - bas)
  
    oldRep's drawInRect:{origin:{x:0, y:padDepth}, |size|:{width:theWidth, height:theHeight}} fromRect:{origin:{x:OX, y:OY}, |size|:{width:(SX), height:(SY)}} operation:(current application's NSCompositeSourceOver) fraction:1.0 respectFlipped:true hints:(missing value)
    -- restore graphics state
    current application's NSGraphicsContext's restoreGraphicsState()
    -- save bitmapImageRep as image
    if {"tif", "tiff"} contains {theExt} then
        set theData to (newRep's representationUsingType:(current application's NSTIFFFileType) |properties|:{NSTIFFCompression:(current application's NSTIFFCompressionLZW)})
    else if {"jpg", "jpeg"} contains {theExt} then
        set theData to (newRep's representationUsingType:(current application's NSJPEGFileType) |properties|:{NSImageCompressionFactor:0.8, NSImageProgressive:true})
    else if theExt = "png" then
        set theData to (newRep's representationUsingType:(current application's NSPNGFileType) |properties|:{NSImageInterlaced:true})
    else -- unsupported type
        return false
    end if
    set theResult to (theData's writeToFile:newPath atomically:true)
    return (theResult as boolean)
end padBottomOfImageAt:byPoints:
tell application "Finder"
    set imp to chemin & nomcourt & "-2.JPEG"
    delay 1
    print imp
    delay 2
    set efface1 to quoted form of POSIX path of (chemin & nomcourt & ".JPEG")
    do shell script "rm " & efface1
end tell