Comments (11)
I corrected the bug.
But I should warn you that most of the time image
won't be equal to image removeTransparency(white)
.
Indeed remove transparency convert the type of the Image to something where you can't write 'alpha' channel anymore, so the equality breaks.
If you are interested only in the value of the pixels you should compare _.pixels.toList
.
It will likely be pushed soon in the maven repo, in the meanwhile you can use the stable
branch of the repository.
from scrimage.
Thank you. I am trying to find ways to detect if the alpha channel is in use, and my first naive idea was to removeTransparency and check for equality. If you can recommend a way of checking for use of alpha channel, please let me know.
from scrimage.
Currently there is no constant time method to do that, because all images automatically receive an alpha channel when loaded. The alpha channel can be removed trough removeTransparency
.
So in the current version I think the more efficient is:
image.pixels map( _ >> 24) forall( _ == 0xff )
It will return true when the alpha channel of the image is not used.
from scrimage.
Thanks for deploying to maven repo. On a sidenote, can you depend on a git-subfolder in SBT? I added dependency (see below), but the scrimage classes was not available. In the output I saw SBT downloaded 1.4.2, which I then switched to eventually.
lazy val scrimage = RootProject(uri("git://github.com/sksamuel/scrimage.git/core#stable"))
val main = play.Project(appName, appVersion, libraryDependencies).dependsOn(scrimage).settings(
from scrimage.
Sometimes it takes a while to appear on maven
On 27 August 2014 12:09, René Grüner Vangsgaard [email protected]
wrote:
Thanks for deploying to maven repo. On a sidenote, can you depend on a
git-subfolder in SBT? I added dependency (see below), but the scrimage
classes was not available. In the output I saw SBT downloaded 1.4.2, which
I then switched to eventually.lazy val scrimage = RootProject(uri("git://github.com/sksamuel/scrimage.git/core#stable"))
val main = play.Project(appName, appVersion, libraryDependencies).dependsOn(scrimage).settings(
—
Reply to this email directly or view it on GitHub
#55 (comment).
from scrimage.
You may have misunderstood me - I am using the newest version with the fix (1.4.2) from maven, hence my thanks for deploying to maven repo :)
I did have troubles when I tried using the stable version from github, as the core is a subfolder/subproject of the root.
from scrimage.
ah ok
On 27 August 2014 12:32, René Grüner Vangsgaard [email protected]
wrote:
You may have misunderstood me - I am using the newest version with the fix
(1.4.2) from maven, hence my thanks for deploying to maven repo :)I did have troubles when I tried using the stable version from github, as
the core is a subfolder/subproject of the root.—
Reply to this email directly or view it on GitHub
#55 (comment).
from scrimage.
@gwenzek your alorithm returns false on a JPG image (notice, it is a jpeg even though it status png).
def getImageContents(url: String): Array[Byte] = {
import scala.language.postfixOps
import scala.io._
import scala.sys.process._
import java.io.{ByteArrayOutputStream, File, InputStream}
import java.net.URL
val image = new ByteArrayOutputStream()
new URL(url) #> image ! ;
image.toByteArray
}
scala> com.sksamuel.scrimage.Image(util.ResizeImages.getImageContents("http://i.imgur.com/7ce5j26s.png")).pixels map(_ >> 24) forall(_ == 0xff)
res8: Boolean = false
Additionally it seems like the BufferedImage.getcolorModel.isAlpha is wrong as well:
com.sksamuel.scrimage.Image(util.ResizeImages.getImageContents("http://i.imgur.com/7ce5j26s.png")).toBufferedImage.getColorModel.hasAlpha
from scrimage.
I forgot a part:
def useAlpha(img: Image): Boolean = !(img.pixels map( _ >> 24 & 0xff) forall( _ == 0xff ))
from scrimage.
9b4de9e adds a usesAlpha
method to Image.
from scrimage.
Thanks - helps a pixel-ignorant like me a lot.
I am still baffled by the behaviour or the JDK method BufferedImage.getColorModel.hasAlpha on JPG a image.
from scrimage.
Related Issues (20)
- Unable to use composite on images HOT 1
- WebP & ImageOutputStream HOT 2
- on amazon linux ,error occur HOT 5
- WebP parsing is broken on latest version HOT 2
- Feature Request: Scala 3 support HOT 2
- PNG image compression ineffective HOT 1
- Some filters don't work for non ARGB images HOT 4
- StreamingGifWriter#withInfiniteLoop method doesn't work correctly HOT 3
- How to write text on image
- ARM (M1/M2) support for WEBP HOT 14
- average implementation is not correct HOT 2
- Security vulnerability in the webp library. HOT 1
- Typo in microsite HOT 1
- Unable to Read JPEG Files HOT 5
- WebP is supported on mac-arm64 without extra configurations
- WebpWriter multiThread always false? HOT 2
- Reset Stream after reading ImageMetadata HOT 4
- Consider vendoring com.github.zh79325:open-gif HOT 1
- strange error in some cases HOT 2
- Animated Webp reading support
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 scrimage.