diff --git a/Codec/Picture/RGBA8.hs b/Codec/Picture/RGBA8.hs
--- a/Codec/Picture/RGBA8.hs
+++ b/Codec/Picture/RGBA8.hs
@@ -40,12 +40,24 @@
             else r
     {-# INLINE pix #-}
 
-trimImage :: Image PixelRGBA8 -> (Int, Int) -> (Int, Int) -> Image PixelRGBA8
+-- | Note: Accessing out of the image causes a segfault.
+trimImage :: Image PixelRGBA8
+    -> (Int, Int) -- ^ width, height
+    -> (Int, Int) -- ^ the left corner point
+    -> Image PixelRGBA8
 trimImage (Image w _ vec) (w', h') (x0, y0) = unsafePerformIO $ V.unsafeWith vec $ \ptr -> do
     mv <- MV.unsafeNew $ w' * h' * 4
-    MV.unsafeWith mv $ \dst -> forM_ [0..h'-1] $ \y -> do
+    MV.unsafeWith mv $ \dst -> forM_ [0..h'-1] $ \y -> 
         copyBytes (plusPtr dst $ y * w' * 4) (plusPtr ptr $ (*4) $ (y + y0) * w + x0) (4 * w')
     Image w' h' `fmap` V.unsafeFreeze mv
+
+-- | Note: Accessing out of the image causes a segfault.
+patchImage :: Image PixelRGBA8 -> (Int, Int) -> Image PixelRGBA8 -> Image PixelRGBA8
+patchImage (Image w h target) (x0, y0) (Image w' h' vec) = unsafePerformIO $ V.unsafeWith vec $ \ptr -> do
+    mv <- V.thaw target
+    MV.unsafeWith mv $ \dst -> forM_ [0..h'-1] $ \y ->
+        copyBytes (plusPtr dst $ (*4) $ (y + y0) * w + x0) (plusPtr ptr $ (*4) $ y * w') (4 * w')
+    Image w h `fmap` V.unsafeFreeze mv
 
 flipVertically :: Image PixelRGBA8 -> Image PixelRGBA8
 flipVertically (Image w h v) = unsafePerformIO $ V.unsafeWith v $ \ptr -> do
diff --git a/JuicyPixels-util.cabal b/JuicyPixels-util.cabal
--- a/JuicyPixels-util.cabal
+++ b/JuicyPixels-util.cabal
@@ -1,5 +1,5 @@
 name:                JuicyPixels-util
-version:             0.1
+version:             0.2
 synopsis:            Convert JuicyPixel images into RGBA format, flip, trim and so on
 description:         
 homepage:            https://github.com/fumieval/JuicyPixels-util
