I’m using TexturePacker from the command line and am unable to get it to pack multiple sprites into 1 sheet. It allows me to do 1 sprite so the command is fine.
This is the command I am using.
"TexturePacker --format sparrow --texture-format atf --opt DXT5
--max-width 2048 --max-height 2048 --size-constraints POT --pack-mode Best --enable-rotation --trim-mode Trim --algorithm MaxRects
--multipack --border-padding 5 --shape-padding 5 --reduce-border-artifacts --scale " + sheetInfo.scale + " --data " + imageOutputDirectory + "\" + lanfPrefix + "\" + sheetInfo.name +
".xml " + "--sheet " + imageOutputDirectory + "\" + lanfPrefix + "\"
+ sheetInfo.name + ".atf image1.png image2.png";
Any ideas why this isn't working? According to the documentation, it should work.
I was unable to find any real way to fix this even contacted the developer of texture packer but got no response. Instead I was able to accomplish the desired outcome by copying all needed files to a temp directory and then add the directory to the end of the texturepacker call instead of individual images.
Due to the poor TexturePacker documentation, it took me much trial and error to figure this out!
To add multiple images to a single sprite sheet, here is a sample command that will create an atlas called out.png (the default) containing images img_1 to img_4...
TexturePacker --format unity-texture2d img_1.png img_2.png img_3.png img_4.png
The key is the list of image filenames separated only by spaces. I am working from Python, so here is the script I use to create the same atlas that the sample line above will give you. Using glob with wildcards allows me to select images from a folder containing many images and eliminates the need to isolate the files I want into a folder just for TexturePacker's sake.
import subprocess, glob
TP = r"C:\Program Files\CodeAndWeb\TexturePacker\bin\TexturePacker.exe"
baseFrame = "img"
def FillAtlas(baseFrame):
globString = baseFrame + "_*.png"
frameList = glob.glob(globString)
imgList = []
for frame in frameList:
imgList.append(frame)
TPargs = [TP, "--format", "unity-texture2d"] + imgList
subprocess.call(TPargs)
FillAtlas(baseFrame)
Related
I'm using an action inside a form to create a Word document, using the CreateObject("Word.application") method, then I modify it to my liking and save it in a temp directory.
I can show the Word document as soon as it is created by calling nameOfTheDocument.visible(true), and by modifying the Save action I can save the newly created document as a PDF, however I can't find a way to show it to the user.
Trying to call visible(true) on the PDF object results in error "Instance member VISIBLE does not exist"
Hmmm... The best and right way - use OS file association.
I'm use java way:
//Win
Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + filePath);
p.waitFor();
//MacOS.*Nix
Process p = Runtime.getRuntime().exec("/usr/bin/open " + filePath);
p.waitFor();
But you can call this command on Lotusscript:
Shell({rundll32 url.dll,FileProtocolHandler } & fullFilePath,1)
'or
Shell({/usr/bin/open } & fullFilePath,1)
We have used the Shell command to launch PDFs in the past. Something like the below. The only downside to this is if the location of the executable changes (whether from upgrade or change to a different program) the code breaks.
Dim ProgPath$, FilePath$
Dim result As Integer
'Path of the executable
ProgPath$ = |"C:\Program Files (x86)\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe"|
'Path of the file to open
FilePath$ = | "C:\TestFile.PDF"|
result = Shell(ProgPath$ & FilePath$,1)
I have to perform the following steps on set of images via matlab GUI:
Read multiple images from directory
Process them (Apply imadjust on each image)
Store them in user specified or same directory while renaming them
Can someone kindly provide me the code for the same? I am stuck after this:
[filename, pathname,~] = uigetfile( ...
{'*.jpg;*.jpeg;',...
'JPEG Files (*.jpg,*.jpeg)';
'*.png', 'PNG files (*.png)'; ...
'*.bmp','BMP File (*.bmp)'; ...
'*.tiff;*.tif','TIFF Files (*.tiff,*.tif)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file',...
'Multiselect','on');
set(handles.inputpathtext,'String',pathname);
[file_name_list, pathname] = uigetfile({'your filter spec','Multiselect','on');
The line above should give you a cell array containing the names of the files you selected. The following code loops through the cell array, read image, perform some adjustement, and save them with 'processed_' prefix added to the file name in the same folder specified by pathname.
for ii = 1:length(file_name_list)
if iscell(file_name_list)
filename = file_name_list{ii};
else
filename = file_name_list;
end
img = imread(fullfile(pathname, filename));
img = imadjust(img); % Do something to the image
imwrite(img, fullfile(pathname, ['processed_', filename])
end
I need to import multiple images (10.000) in Matlab (2013b) from a subdirectory of the predefined directory of Matlab.
I don't know the exact names of the images.
I tried this:
file = dir('C:\Users\user\Documents\MATLAB\train');
NF = length(file);
for k = 1 : NF
img = imread(fullfile('C:\Users\user\Documents\MATLAB\train', file(k).name));
end
But it throws this error though I ran it with the Admin privileges:
Error using imread (line 347)
Can't open file "C:\Users\user\Documents\MATLAB\train\." for reading;
you may not have read permission.
The "dir" command returns the virtual directory elements "." (self directory) and ".." parent, as your error message shows.
A simple fix is to use a more specific dir call, based on your image types, perhaps:
file = dir('C:\Users\user\Documents\MATLAB\train\*.jpg');
Check the output of dir. The first two "files" are . and .., which is similar to the behaviour of the windows dir command.
file = dir('C:\Users\user\Documents\MATLAB\train');
NF = length(file);
for k = 3 : NF
img = imread(fullfile('C:\Users\user\Documents\MATLAB\train', file(k).name));
end
In R2013b you would have to do
file = dir('C:\Users\user\Documents\MATLAB\train\*.jpg');
If you have R2014b with the Computer Vision System Toolbox then you can use imageSet:
images = imageSet('C:\Users\user\Documents\MATLAB\train\');
This will create an object containing paths to all image files in the train directory, regardless of format. Then you can read the i-th image like this:
im = read(images, i);
Is there a way to basically print my own output during a command line render?
Let's say I don't need/want all the other output that maya spits out by default, I know you can change the verbosity level, but there's very specific things I'd like to output but I can't figure it out. I currently render out the verbosity output to file, so I wanted to print in the terminal (I'm using MAC) the frame that the render is currently up to.
This may just be simple minded, but here's what I tried:
Render -preFrame "print `currentTime -q`;" -s 1 -e 20 -rd /render/directory/ maya_file.mb
Obviously, -preFrame expects a string, according to the docs this can take mel commands, but obviously this is limited to certain commands, I'm assuming the currentTime command is pulling the information from the timeline in maya, not queering it from the Renderer it self... When I run the above command, straight away, it spits out this: -bash: currentTime: command not found and soon after the render fails/doesn't start.
Idealy, I'd like to print the following as it starts each frame:
"Started rendering frame XXXX at TIME GOES HERE", that way, I can quickly look at the terminal, and see if the renderer has failed, stuck or where it's up to and when it started it.
So my question is, seeing is currentTime is a mel command used from within Maya, is there another way I could print this information?
Cheers,
Shannon
After many hours of searching for this answer, I ended up finding out that you can start maya as an interactive shell. By doing this, I was able to source a script as I opened it, and run whatever I want into memory as If I had Maya open at the time.
/Applications/Autodesk/maya2014/Maya.app/Contents/MacOS/maya -prompt -script "/Volumes/raid/farm_script/setupRender.mel"
In the setupRender.mel file, I was able to assign variables, containing options for renders etc, in doing this, I was also able to create a global variable for the frame number, and increment it during the preFrame callback, like so:
int $startFrame = 100;
int $endFrame = 1110;
global int $frameCount = 0;
string $preRenderStatistics = "'global int $frameCount; $frameCount = " + $startFrame + ";'";
string $preFrameStatistics = "'print(\"Rendering frame: \" + $frameCount++)'";
string $additionalFlags = "";
string $sceneFilePath = "'/Volumes/path/to/file/intro_video_001.mb'";
system("Render -preRender " + $preRenderStatistics + " -preFrame " + $preFrameStatistics + " -s " + $startFrame + " -e " + $endFrame + " -x " + $additionalFlags + " " + $sceneFilePath);
This is a very simplified version of what I currently have, but hopefully this will help others if they stumble across it.
Take a look at the pre render layer MEL and/or pre render frame MEL section of the Render Settings.
It expects MEL, so you'll either need to write it in MEL or wrap your python in MEL. For such a simple use, I'd say just write it in MEL:
print `currentTime -q`
I have a problem with paperclip in rails 3. When I upload a file my processor throws error because imagemagick get command:
"composite -gravity South /home/xxx/xxx/public/images/watermark.png /tmp/a s20121207-5819-1dq7y81.jpg /tmp/a s20121207-5819-1dq7y8120121207-5819-1juqw7a"
composite: unable to open image `/tmp/a':
processor:
def make
dst = Tempfile.new([#basename, #format].compact.join("."))
dst.binmode
if #watermark_path
command = "composite"
params = "-gravity #{#position} #{#watermark_path} #{fromfile} "
params += tofile(dst)
begin
p " >>>>>>>>>>>>>>>>> #{command} #{params}"
success = Paperclip.run(command, params)
rescue PaperclipCommandLineError
success = false
end
unless success
raise PaperclipError, "There was an error processing the watermark for #{#basename}" if #whiny
end
return dst
else
return #file
end
end
def fromfile
File.expand_path(#file.path)
end
def tofile(destination)
File.expand_path(destination.path)
end
it only occurs when filename have whitespace or other non alfanum chars. The /tmp/a should be /tmp/a b.jpg.
I'va tried http://www.davesouth.org/stories/make-url-friendly-filenames-in-paperclip-attachments and more but still filename in processor is wrong
any ideas? or processor that works ok for this issue? :(
Try it maybe with:
dst = Tempfile.new([#basename, #format].compact.join(".").gsub(" ","")
I came back to this today and figured out you just need to enclose the path with a quote as in the ImageMagic documentation (http://www.imagemagick.org/script/command-line-processing.php):
If the image path includes one or more spaces, enclose the path in quotes:
'my title.jpg'
As an example, in my processor I have:
command = "convert \"#{File.expand_path(#file.path)}\" -crop #{crop_area} -resize 150x150 \"#{File.expand_path(destination.path)}\""
Paperclip.run(command)
.
I am on Windows at the moment and single quote doesn't seem to work.
Like you, I tried changing attributes of #file with no success.
Hope it helps.