Iconutil giving error - xcode4

I have been getting this error for 2 days in response to iconutil -c icns iconset.iconset:
ImageIO: _CGImagePluginWriteICNS unsupported image size (128 x 128) - scaling factor: 2
ImageIO: _CGImagePluginWriteICNS unsupported image size (16 x 16) - scaling factor: 2
The iconset.iconset folder has 10 .png files icon_512x512#2x.png, icon_512x512.png...and the versions for 256, 128, 32, 16.
The resulting iconset.icns file has only 8 images.
I'm running xcode 4.5 on Lion.
I have searched and searched for an answer. If I just remove the offending 128x128#2x and the 16x16#2x, the message is these files are missing.
Very grateful for any help.

I realized the answer to my question:
The #2x files should have an image size 2x, e.g. icon_128x128.png has image size 128x128 px, but icon_128x128#2x.png actually must have an image size of 256x256 px.
When I asked the question, I did not realize this and my image sizes were the same for each pair.
Hope this helps someone

Related

I am trying to save 360 png files as a gif with image magick in R (I am working with MacOS)

please let me know any other system/code I need to include, as I am not as familiar with writing out images to my computer. I am creating 360 png files as follows:
for(theta in 1:360){
ic=as.character(theta)
if(theta<10) ic=paste("00",ic,sep="")
if(theta>=10 & theta<100) ic=paste("0",ic,sep="") # make filenames the same length
fn=paste("c:iris360\\HW4_",ic,".png",sep="") #filename
png(fn,width=1000,height=1000) # save as *.png
p3(X1,X2, r=100,theta=theta,mainL=paste("theta =",theta))
# legend("topleft",pch=16,cex=1.5,col=allcl)
dev.off()
}
system("magick c:iris360\\HW4*.png c:iris.gif")
where p3 is just a function that takes my matrices X1 and X2 and plots the points and their segments(let me know if I need to include it as well). However, I get this error:
magick: must specify image size iris360HW4*.png' # error/raw.c/ReadRAWImage/140.
I am unable to open the gif file, as my mac says it is damaged or uses a file format that preview does not recognize.
Update 1: I replaced fn's declaration with
fn <- sprintf("c:iris360/HW4_%03i.png", theta)
as well as replacing ic with sprintf("%03i", theta) everywhere it appeared, but still got the same specify image size error.
When I run the system command into my terminal, I still get the same error asking me to specify the image size.
Magick needs to know several things (e.g., image size, delay between frames, images to use, destination file name) in order to convert a stack of png into a gif. See GIF Animations and Animation Meta-data
magick -delay 100 -size 100x100 xc:SkyBlue \
-page +5+10 balloon.gif -page +35+30 medical.gif \
-page +62+50 present.gif -page +10+55 shading.gif \
-loop 0 animation.gif
So it looks like you need to change
system("magick c:iris360\\HW4*.png c:iris.gif")
to something more like
system("magick -delay 10 -size 100x100 —loop 0 c:iris360\\HW4*.png c:iris.gif")

Read pdf page size on .NET Core

I have only one requirement. I need to read PDF page size and determine if page is not bigger then 17x17 inches to not send it to some external service which rejects such pdfs.
Is there any free library working on .NET Core? I wasn't able to find it. Or maybe anyone implemented this by reading binary file?
A pdf does not HAVE TO declare page size externally since every page can be a different size thus 100 pages may be 100 different page sizes.
However many PDF will contain a text entry for one or more pages so you can (depending on construction) parse as text for /MediaBox and or potentially /CropBox dimensions.
So the first PDF example I pick on and open to search for /MediaBox in WordPad tells me its 210 mm x 297 mm (i.e my local A4) /MediaBox [0 0 594.95996 841.91998] and for a 3 page file all 3 entries are the same.
you can try that using command line as
type "filename.pdf" | find /i "/media"
but may not work in all cases so a bigger chance of result (but more chaff) is
type "filename.pdf" | findstr /i "^/media ^/crop"
The value is based on the default number of point size units per inch (so can be divided by 72 as a rough guide), however, thats not your aim since you know you dont want more that 17x72=1224.
So in simple terms, if either value was over 1224 then I could reject as "TOO BIG".
HOWEVER I need to also consider those two 0 values, thus if one was +100 then the limit becomes 100 more and more importantly, if one was -100 then your desired 17" restriction will fail at 1124.
So you can write in any method or language (even CMD) a simple test, however, that will require too much expanding to cover all cases, SO:-
Seriously I would use / shell a one line command tool like xpdf/poppler pdfinfo to parse all different types of PDF and then grep that output.
The output is similar for both with many lines but for your need
xpdf\pdfinfo -box filename
gives Page size: 594.96 x 841.92 pts (A4) (rotated 0 degrees)
and
poppler\pdfinfo -box filename
gives Page size: 594.96 x 841.92 pts (A4)
Thus to check the file does not exceed 17" (in either direction) it should be easy to set a comparison testing that both values are under 1224.01

Open only part of an image (JPEG/TIFF etc.) in R

I am analysing very large images in R, in the order of tens of thousands of pixels square. Unfortunately, even with 64 GB RAM, these images sometimes fail to fit into memory, and when they do I can only open one at a time, precluding parallelisation.
My current strategy is to load them using the JPEG or TIFF packages. e.g.:
image <- readJPEG('image.jpg')
However, as I am only performing simple mathematical manipulations (summing, thresholding etc.) that could be performed piece-by-piece, is it possible to only open part of an image at a time by specifying the dimensions to load? If so, I could write a loop to open 1024 x 1024 sized tiles. The JPEG and TIFF packages do not offer an option to do this.
If you are working with very large images, libvips is probably your best bet. You can shell out to it from R using system().
Your question is not very specific, but let's make a 10,000x10,000 pixel TIFF with ImageMagick and it is a black-white gradient:
convert -size 10000x10000 gradient: -depth 8 a.tif
Now threshold that at 50% with vips and check memory required:
vips im_thresh a.tif b.tif 128 --vips-leak
memory: high-water mark 292.21 MB
Pretty frugal, no? By comparison, the equivalent ImageMagick command requires 1.6GB of RAM:
/usr/bin/time -l convert a.tif -threshold 50% b.tif
Sample Output
...
1603895296 maximum resident set size
...
How about adding 64 to every pixel using im_gadd which does:
usage: vips im_gadd a in1 b in2 c out
where:
a is of type "double"
in1 is of type "image"
b is of type "double"
in2 is of type "image"
c is of type "double"
out is of type "image"
calculate a*in1 + b*in2 + c = outfile
So we use:
vips im_gadd 1 a.tif 0 b.tif 64 c.tif --vips-leak
memory: high-water mark 584.41 MB
Need to do some statistics?
vips im_stats c.tif
band minimum maximum sum sum^2 mean deviation
all 64 319 1.915e+10 4.20922e+12 191.5 73.6206
1 64 319 1.915e+10 4.20922e+12 191.5 73.6206
As it turns out, there is an R package - RBioFormats - that allows you to specify part of an image being opened (though it is not available on CRAN). It can be installed from Git as follows:
source("https://bioconductor.org/biocLite.R")
biocLite("aoles/RBioFormats") # You might need to first run `install.packages("devtools")`
library(RBioFormats)
The dimensions of the image can be read from the metadata without having to open the image:
metadata <- read.metadata('image.tiff')
xdim <- metadata#.Data[[1]]$sizeX
ydim <- metadata#.Data[[1]]$sizeY
Suppose that we want to load the top-left 512 x 512 pixels, we use the subset function:
image <- read.image('image.tiff', subset = list(X = 1:512, y = 1:512))
From this it is trivial to write a loop to iteratively process a whole large image. RBioFormats is an R interface into the Java BioFormats library and will open Tiffs, PNGs, JPEGs as well as many proprietary imaging formats.

add background to a gif containing images of different sizes (R magick)

I would like to add an image background to a gif which contains images of different sizes like this beautiful christmas ball.
Here is the code i tried :
#install.packages("magick")
library(magick)
setwd("C:/Users/...")
christmas <- image_read('christmas.gif')
background <- image_blank(250, 250, color = "red")
frames <- image_composite(background, christmas, offset = "+0+0")
animation <- image_animate(frames, fps = 5)
image_write(animation, "output.gif", format="gif")
And here is the horrible result !!
The problem is that the 3 images of the ball gif are not of the same size so the images are moving when adding a background image.
> christmas
format width height colorspace matte filesize
1 GIF 216 249 sRGB TRUE 47656
2 GIF 202 233 sRGB TRUE 47656
3 GIF 200 214 sRGB TRUE 47656
I didn't find how to fix this problem... : If you could help me before christmas it would be great !!!
Thanks !
Your problem is likely that you need to coalesce the frames to fill them out to the same size. Then later optimize them again. In ImageMagick, I would do:
convert ornament.gif -coalesce -background red -alpha background -alpha off -layers optimize ornament2.gif
See
http://www.imagemagick.org/script/command-line-options.php#coalesce
http://www.imagemagick.org/Usage/masking/#alpha
http://www.imagemagick.org/Usage/anim_opt/#optimize
Sorry I do not know the equivalent commands in RMagick. But they likely have similar names. Hopefully, this will get you pointed in the right direction.

How to exchange the width and height of W35 Touchscreen for Mini2440 FriendlyARM embedded board

I have a Friendly-ARM embedded board with a W35 3.5" Touchscreen. You can see the board via the following link: http://www.friendlyarm.net/sites/products/mini2440-35s.jpg. Also I write QT program for that using Qt Creator. I have to write a GUI using QT with Width x Height = 240 x 320. I mean width = 240 and height = 320. According to what I found at various online documents and pages, the dimensions of W35 are 320 x 240, it means width = 320 and height = 320. So when I run the program, there are large margins at left and right and some part of GUI is cut at top and button. How do I exchange the board width and height?
The closest page I found on Friendly-ARM site is: http://www.friendlyarm.net/forum/topic/2881.
At this page someone mentioned, there is a file s3c2410.c at drivers/video directory, or there is file mach-mini2440.c at arch/arm/mach-s3c2440 directory and we should tweak some C #define, but I don't have neither one on the board kernel. What should I do?
1) Reinstalling the Kernel?
2) Writing program for 320 x 240 instead of 240 x 320
3) Changing the touchscreen to similar ones like X35 or T35
FYI, when the board starts up, there is Qtopia with right dimensions.
TIA,
-- Saeed Amrollahi Boyouki
First of all cross-compile your Qt with -qt-gfx-transformed option.
Method 1:
You can rotate your Qt Application using
./myApp -qws -display ":Transformed:Rot90:0"
Method 2:
You can set Display Dimension using
export QWS_DISPLAY=Transformed:Rot90:0
and start your application using
./myApp -qws
What you need to look for are instructions to rotate the display from "landscape" mode to "portrait" mode. I am unsure if there is a hardware option on the ARM processor included in the FriendlyArm, but that gives you a place to start searching. I'd also look in the Qtopia forums for a similar switch, ie http://qt-project.org/forums/viewthread/8875 or similar.

Resources