resizing an original image result in a fluo green image - imageresizer

normal image: https://www.4office.be/images/products/7093442.jpg
resized : https://www.4office.be/images/products/7093442.jpg?w=360&h=360
probably corrupt original?
how to correct?
tx
Luc

Related

Metal Sampler ::linear doesn't work as expected

My source image is a 512x512 pixels checkerboard (see source image). When I render it to 1/3 of its size (170,6.. x 170,6..) the result looks like it is downsized with the ::nearest filter. I expect the resulting image to be an approximation of texels (colors) sampled by the sampler in my texture shader, but it is not. I tried to do the same using CALayer, and the result was identical. However, resizing NSImage created with my source image (512x512) to 1/3.0 of size produced the expected result (see image below). Please, could you explain how the sampler in Metal works and what I need to change to get the result I expect?
Thank you.
(I render to CAMetalLayer's drawable, contentsScale #1x, displayScale #1x)
My texture shader sampler: constexpr sampler textureSampler (mag_filter::linear, min_filter::linear);
Source image 512x512:
Result 170,6.. x 170,6..:
Expected result 170,6.. x 170,6..:
I made two mistakes:
I didn't create mipmaps from my source texture
Because I didn't create mipmaps and I didn't use: mip_filter::linear parameter for sampler.
Generating mipmaps and using:
constexpr sampler samplerLinear(min_filter::linear, mag_filter::linear, mip_filter::linear);
Renders correct output texture.

AVISynth's ImageWriter is giving blank PNG files

Title says it all really.
BlankClip(length=100,width=1920,height=1080,pixel_type="RGB32",fps=60,color=$ff0000)
\ .ImageWriter("frames/%05d.png",type="png")
Expected result: 100 red images
What I got: 100 transparent images
I've tried the internal ebmp format, and that does give red images, but the "real thing" will have a transparent background and this is flattened to black. That aside, the frames are 7MB each which is just silly (real thing has 5-digit numbers of frames).
Any ideas?
Since you select "RGB32" format for BlankClip, you should provide the alpha channel in "color" parameter as well.
Apparently it's in ARGB format, so you should set it to $ffff0000 (first "ff" is for full opaqueness).

GraphicsMagick crop PDF

I've got a 8.5x11 PDF at 300dpi. It has a single UPC label in the top left corner of the PDF. Imagine that there could be 30 labels on a 1 sheet, but we just have 1 label.
I'm trying to crop the PDF to be just the size of the 1 label. So far I've got this
gm convert -density 300 single.pdf out.pdf
Which doesn't do any cropping. When I crop to say 300x100 it makes a 20MB file with 30000 pages.
I have not a clue how to use -crop to actually crop to the correct size. I need it to be 3.5inches by 1.125 inches.
Using the following input PDF (here converted to a PNG):
the following command will crop the label:
gm wiz.pdf -crop 180x50+1+1 cropped.pdf
This label is sized 180x50 pixels.
For an 8.5x11in PDF at 300 PPI you'd have a 2450x3300 pixels PDF (which I doubt you do, but that's another question) and you'd need to use -crop 1050x337+0+0 (more exactly, 1050x337.5+0+0 -- but you cannot crop half pixels!).
Note, the +0+0 part crops the top left corner. If you need offset to the right by N pixels and to the bottom by M pixels use +N+M...
Using ImageMagick instead...
You could also use ImageMagick's convert command:
convert wiz.pdf[180x50+1+1] cropped.pdf
Comment about image sizes...
One additional comment about this remark:
"I have not a clue how to use -crop to actually crop to the correct size."
There is no other real size for raster images than pixels. ABC pixels wide and XYZ pixels high...
There is no such thing as an absolute, real size for a digital image that you can measure in inches... unless you additionally can state the resolution at which a given image is rendered on a display or a print device!
An 8.50x11in sized image at 300 PPI will translate to 2550x3300 pixels.
However, if your image does not contain this amount of pixels (which is the real, absolute size of any raster image), you may still be able to render it at 300 PPI -- but its size in inches will be different from 8.5x11in!
So, whenever you want to crop, use the absolute number of pixels you want. Don't use resolution/density at all on your command line!

create a new image with only masked part (without transparent area) with new size

I have a mask and an image on which mask is applied to get a portion of that image.
The problem is when I apply that mask on the image ,the resultant image from masking is of same size as the original image .Though the unmasked part is transparent. What I need is an image which only has the masked part of the original image ,I dont want transparent part to be in the image. so that the resultant image will be of smaller size an contain only the masked part.
Thanks
You can:
Draw the image to a new CGBitmapContext at actual size, providing a buffer for the bitmap. CGBitmapContextCreate
Read alpha values from the bitmap to determine the transparent boundaries. You will have to determine how to read this based on the pixel data you have specified.
Create a new CGBitmapContext providing the external buffer, using some variation or combination of: a) a pixel offset, b) offset bytes per row, or c) manually move the bitmap's data (in place to reduce memory usage, if possible). CGBitmapContextCreate
Create a CGImage from the second bitmap context. CGBitmapContextCreateImage

How to replace all pixels of some color in a bitmap in Rebol?

Let's say I have a picture, I want to create some variations by changing a color. How to do this ?
I don't want to apply color filter to a picture, I want to change pixels color pixel by pixel by testing a color pixel if it is let's say red, i want to turn it to blue.
In Rebol images are also series, so you can use most of the series functions to change/find rgb colors etc.
i: load %test.png
type? i
image!
first i
255.255.255.0 (the last value is alpha)
change i 255.0.0.0 ;change the first rgba value to red
view layout [image i] ;you can see the upper-left pixel is now red
you can dump all rgba values in an image:
forall i [print first i]
you can also change a continues part:
change/dup head i blue 100 ;change first 100 pixels to blue
you can also work on i/rgb and i/alpha, these are binary values (bytes)
and you can use copy to get a part of an image:
j: copy/part at i 100x100 50x50 ;copy from 100x100 to 150x150 to a new image.
Use some of the image processing capabilities as documented here:
http://www.rebol.com/docs/view-guide.html
Demo program showing some of them in action here:
http://www.rebol.com/view/demos/gel.r