Bram Neijt
2014-08-19 15:44:22 UTC
Hi,
I'm a Haskell beginner and wanted to use gtk2hs to load, scale and
save a jpeg image.
The code I have so far is:
import Graphics.UI.Gtk.Gdk.Pixbuf
import System.Glib.UTFString
import qualified Data.Text as T
jpegImageFormat :: ImageFormat
jpegImageFormat = pixbufGetFormats !! 6
pixbufSaveJpeg :: Pixbuf -> FilePath -> IO()
pixbufSaveJpeg pb toPath =
pixbufSave pb toPath jpegImageFormat []
scaleFile :: FilePath -> FilePath -> IO ()
scaleFile fromPath toPath = do
original <- pixbufNewFromFile fromPath
scaled <- pixbufScaleSimple original 800 800 InterpHyper
putStrLn toPath
pixbufSaveJpeg scaled toPath
main = scaleFile "hanginthere.jpg" "scaledinthere.jpg"
The ghc 7.8.3 will complains with:
src/Main.hs:18:9:
No instance for (GlibString string0)
arising from a use of ‘pixbufSave’
The type variable ‘string0’ is ambiguous
Note: there are several potential instances:
instance GlibString T.Text -- Defined in ‘System.Glib.UTFString’
instance GlibString [Char] -- Defined in ‘System.Glib.UTFString’
In the expression: pixbufSave pb toPath jpegImageFormat []
In an equation for ‘pixbufSaveJpeg’:
pixbufSaveJpeg pb toPath = pixbufSave pb toPath jpegImageFormat []
How can I solve this? Are there any examples of using pixbufSave?
Greetings,
Bram
I'm a Haskell beginner and wanted to use gtk2hs to load, scale and
save a jpeg image.
The code I have so far is:
import Graphics.UI.Gtk.Gdk.Pixbuf
import System.Glib.UTFString
import qualified Data.Text as T
jpegImageFormat :: ImageFormat
jpegImageFormat = pixbufGetFormats !! 6
pixbufSaveJpeg :: Pixbuf -> FilePath -> IO()
pixbufSaveJpeg pb toPath =
pixbufSave pb toPath jpegImageFormat []
scaleFile :: FilePath -> FilePath -> IO ()
scaleFile fromPath toPath = do
original <- pixbufNewFromFile fromPath
scaled <- pixbufScaleSimple original 800 800 InterpHyper
putStrLn toPath
pixbufSaveJpeg scaled toPath
main = scaleFile "hanginthere.jpg" "scaledinthere.jpg"
The ghc 7.8.3 will complains with:
src/Main.hs:18:9:
No instance for (GlibString string0)
arising from a use of ‘pixbufSave’
The type variable ‘string0’ is ambiguous
Note: there are several potential instances:
instance GlibString T.Text -- Defined in ‘System.Glib.UTFString’
instance GlibString [Char] -- Defined in ‘System.Glib.UTFString’
In the expression: pixbufSave pb toPath jpegImageFormat []
In an equation for ‘pixbufSaveJpeg’:
pixbufSaveJpeg pb toPath = pixbufSave pb toPath jpegImageFormat []
How can I solve this? Are there any examples of using pixbufSave?
Greetings,
Bram