Comments (3)
About merging filters - I think it's really an interesting idea, I thought of something like this, but for now decided to keep things more simple.
Talking about performance I don't see a big advantage:
- toNRGBA does nothing if the image is already NRGBA, which is true for sequential functions call.
- Sharpen uses Blur, but in your example with another sigma, so recalculation needed anyway.
- image.NewNRGBA - not always needed, but things like gaussian blur cannot be done in-place. I don't think its a big performance penalty.
- different filters need different algorithms and don't fit one conception
But some things indeed could be optimized this way, for example do contrast and brightness adjustments at once.
img.Rotate(90) // Rotate Image 90 degree
rotation here changes image dimensions - this means a new pixel array, a new stride. in this case why not a function returning a new image?
Using functions instead of methods have a big advantage - you can pass any image that implements image.Image interface to imaging.Rotate. in your example img is a special type of image that has Rotate method.
from imaging.
About merging filters - I think it's really an interesting idea, I thought of something like this, but for now decided to keep things more simple.
I appreciate the simplicity but having to call imaging.Method(srcImage
,args)` looked like duplication to me because am force to initialize a variable all the time
firstStep := imaging.MethodA(srcImage, arg)
secoundStep := imaging.MethodB(firstStep , arg)
thirdStep := imaging.MethodC(secoundStep , arg)
Talking about performance I don't see a big advantage:
Valid point , don't like micro optimization.. should have done performance test before bring this up.
rotation here changes image dimensions - this means a new pixel array, a new stride. in this case why not a function returning a new image?
LGTM ... seems like a reasonable approach.
But some things indeed could be optimized this way, for example do contrast and brightness adjustments at once.
Do you want me to implement this ?
rotation here changes image dimensions - this means a new pixel array, a new stride. in this case why not a function returning a new image
That is the mail idea but it can be skipped. From my example it can as well be
img, err := imaging.Open("src.png") // Open Image and Return ImageSrc type
filter, _ := imaging.Filter(img) // Start Filter
imgGray, _ := filter.Grayscale()
imgBlur, _ := filter.Blur(4.5)
imgSharpen, _ := filter.Sharpen(3.0)
imgBrigtness, _ := filter.Brightness(+5)
imgContrast, _ := filter.Contrast(+2)
imgRotate, _ := img.Rotate(90) // Rotate Image 90 degree
imgBackground, _ := img.PasteCenter(backgroundImage) // Paste Image a new Background
This kind of flexibility can be useful because i scan simply call imgGray.Save("dst_gray.jpg")
or imgBlur.Color(0xFFCCDD)
etc which is different for the original image
Using functions instead of methods have a big advantage - you can pass any image that implements image.Image interface to imaging.Rotate. in your example img is a special type of image that has Rotate method.
This changes does not break the current API but rather than implement any code the functions would just be syntactic sugars
Finally
The current implementation & API is fantastic ... am just looking at ways we can make it better :)
from imaging.
Thanks for your feedback! :)
You can reuse a variable:
img = imaging.MethodA(img, arg)
img = imaging.MethodB(img, arg)
img = imaging.MethodC(img, arg)
Do you want me to implement this ?
No, just counting pros and cons
For now i don't see a big advantage to change/update the API this way.
from imaging.
Related Issues (20)
- WebP support HOT 2
- How to get image width from imaging HOT 1
- Cannot apply transparency HOT 1
- imaging.Open throw error: image: unknown format HOT 2
- How to get file from postman HOT 2
- how can we resize image HOT 3
- Does imaging support wartermark text?
- Images not get fully processed even if background is filled with base color? HOT 1
- resize image become bigger HOT 1
- What is the different Resize and Thumbnail functions? HOT 1
- How to convert png-24 to png-8? HOT 1
- Support HEIF (.heic) files with AutoOrientation HOT 1
- Panic in the Rotate90 function.
- Export fixOrientation HOT 1
- Paste function panics
- Rotated image background won't blend according to Alpha when pasting
- Specific image will cause the index of the scan function in scanner.go to go out of bounds
- Snyk reports vulnerability HOT 1
- Maybe it's time to release version 1.6.3 so as not to have to go to the master branch for it
- 5 years doesn't update?
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 imaging.