scaleimage (empty) → 0.1
raw patch · 4 files changed
+118/−0 lines, 4 filesdep +basedep +filepathdep +gdsetup-changed
Dependencies added: base, filepath, gd
Files
- LICENSE +30/−0
- Main.hs +60/−0
- Setup.lhs +3/−0
- scaleimage.cabal +25/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2008 Don Stewart++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.++3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+POSSIBILITY OF SUCH DAMAGE.
+ Main.hs view
@@ -0,0 +1,60 @@+--------------------------------------------------------------------+-- |+-- Module : scale an image+-- Copyright : (c) Galois, Inc. 2008+-- License : BSD3+--+-- Maintainer: Don Stewart <dons@galois.com>+-- Stability : provisional+-- Portability:+--+--------------------------------------------------------------------++import System.Environment+import System.IO+import System.Exit+import Data.Char++import System.FilePath+import Graphics.GD++main = do+ args <- getArgs+ (x,y,f,g) <- case args of+ [sx,sy,f,g] -> case do x <- maybeRead sx+ y <- maybeRead sx+ Just (x,y,f,g) of+ Nothing -> die+ Just g -> return g+ _ -> die++ load <- case map toLower (takeExtension f) of+ ".jpg" -> return loadJpegFile+ ".jpeg" -> return loadJpegFile+ ".png" -> return loadPngFile+ ".gif" -> return loadGifFile+ _ -> die++ save <- case map toLower (takeExtension g) of+ ".jpg" -> return (saveJpegFile 95)+ ".jpeg" -> return (saveJpegFile 95)+ ".png" -> return savePngFile+ ".gif" -> return saveGifFile+ _ -> die++ image <- load f+ image' <- resizeImage x y image+ save g image'++------------------------------------------------------------------------++die :: IO a+die = do+ hPutStrLn stderr+ "Usage: scaleimage <x> <y> input.[png,gif,jpg] output.[png,gif,jpg]"+ exitWith (ExitFailure 1)++maybeRead :: Read a => String -> Maybe a+maybeRead s = case reads s of+ [(x, "")] -> Just x+ _ -> Nothing
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ scaleimage.cabal view
@@ -0,0 +1,25 @@+name: scaleimage+version: 0.1+homepage: http://code.haskell.org/~dons/code/scaleimage+license: BSD3+license-file: LICENSE+author: Don Stewart+maintainer: dons@galois.com+category: Graphics+synopsis: Scale an image to a new geometry+description: Scale image is a small command line tool to scale+ an image file to a specified geometry. File types+ supported: png, jpg, gif. Input and output formats+ can differ. Example:+ .+ > scaleimage 128 128 photo.gif photo.png+ .+cabal-version: >= 1.2+build-type: Simple++flag small_base+ description: Choose the new smaller, split-up base package.++executable scaleimage+ build-depends: base, gd, filepath+ main-is: Main.hs