Comments (9)
definitely. not only that, but files load into a DynamicImage, and then i have to patternmatch on all those constructors to get an Image that i can imageWidth, etc on. why isn't DynamicImage a typeclass instead?
from juicy.pixels.
also, instead of a bunch of save* functions, why isn't file type an argument?
saveImage :: FilePath -> ImageType -> DynamicImage -> IO ()
data ImageType = PNG | JPG Int | BMP ...
from juicy.pixels.
DynamicImage can't be a type class, as the image decoders don't know at compilation time which color space the will have to decode (especially for the PNG case). For your use case, it's easy to add a function of the following type
{-# LANGUAGE Rank2Types #-}
withDynamicImage :: (foral pixel. Image pixel -> a) -> DynamicImage -> a
allowing something like withDynamicImage imageWidth
For the saveImage, I don't see any real advantage of providing it as the intended use case is to serialize to a fixed image format, but patches are welcome.
from juicy.pixels.
i'm not clear why your reason precludes a typeclass, but i might be missing something. is there any way to write withDynamicImage without a million patternmatches (which is just doing what a typeclass would do, but in a closed/brittle way)? in any case, why not include it in the library?
regarding saveImage, consider the use case (mine) of writing a thumbnailer -- doesn't care what the original format was, just wants to write out the same format. don't you want to let me write that in a generic way?
from juicy.pixels.
I don't know how to write decodeImage :: B.ByteString -> Either String DynamicImage
with a type class, with the constraint that the caller doesn't know the pixel type (because it can only be known by the decoding function).
For the withDynamicImage, it's the lack of type mainly, but I accept pull requests.
For your specific use case, why not use the imageTo* functions? It seems to me that it answer your use case.
from juicy.pixels.
Since this issue is a bit old, is there any way to determine image width from a dynamic image with a function call? (And your link to imageTo functions seems to have gone dead.)
from juicy.pixels.
The dynamicMap could help extract width and height of a fully extracted image, I've updated the link to the imageTo functions
from juicy.pixels.
Thanks, that was perfect.
from juicy.pixels.
Done with addition of Metadata.
from juicy.pixels.
Related Issues (20)
- Transparent gifs
- EXIF files are misidentified as TIFF instead of JPEG in metadata
- `readMetadata`, without decoding image HOT 2
- Add option to apply JPEG rotation to image
- Width and height incorrect for exif image
- Loosen bounds on bytestring HOT 1
- What does this sentence means?
- Refine(cast) DynamicImage to specific Image HOT 1
- Read EXIF data also from PNGs
- Distortion (and possibly segfault) in decoding a certain JPEG HOT 2
- Impossible - typeOfData : Exifone
- Plans to encode webp? HOT 2
- Loosen bounds on Vector
- add "instance TestEquality Keys"
- Infinite loop in palettize
- The test suite never fails
- `Metadatas` skips over entries that contain non-ascii unicode characters.
- Revise bounds on hackage to allow latest deepseq
- Missing changelog for 3.3.8
- New release? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from juicy.pixels.