[solved] Need help with copy pixels - resize and paste into another region
[solved] Need help with copy pixels - resize and paste into another region
Hello all,
I searched but did not find the solution - maybe someone can help me.
Original: Format *.dds - size 128x128 - position region: 25,36 - size region: 71x48
i want to convert to:
Converted: Format *.dds - size 64x64 - position region: 12,16 - size region: 34x24
I try the convert Option.
Resize to 64x64 works - code for my batchfile:
for %%f in (*.dds) do ( convert %%f -resize 64x64 -define dds:mipmaps=2 -define dds:compression=none "converted\%%f" )
In the moment i would like to do:
1. copy region from original to new image (tempimage1)
2. resize(tempimage1) to new size (tempimage2)
2. create transparent canvas from original (tempimage3)
3. resize transparent canvas(tempimage2) to new size (tempimage4)
4. copy (tempimage2) to new region (tempimage4) (outputimage1)
Is there a way with options to do it in one go? - so without the tempimage's?
would be nice if someone can help me on that topic
Thanks for help
Avanatus
I searched but did not find the solution - maybe someone can help me.
Original: Format *.dds - size 128x128 - position region: 25,36 - size region: 71x48
i want to convert to:
Converted: Format *.dds - size 64x64 - position region: 12,16 - size region: 34x24
I try the convert Option.
Resize to 64x64 works - code for my batchfile:
for %%f in (*.dds) do ( convert %%f -resize 64x64 -define dds:mipmaps=2 -define dds:compression=none "converted\%%f" )
In the moment i would like to do:
1. copy region from original to new image (tempimage1)
2. resize(tempimage1) to new size (tempimage2)
2. create transparent canvas from original (tempimage3)
3. resize transparent canvas(tempimage2) to new size (tempimage4)
4. copy (tempimage2) to new region (tempimage4) (outputimage1)
Is there a way with options to do it in one go? - so without the tempimage's?
would be nice if someone can help me on that topic
Thanks for help
Avanatus
Last edited by Avanatus on 2016-07-08T12:22:00-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Need help with copy pixels - resize and paste into another region
I don't understand what you want. Perhaps you want to:
(1) From an input image that is 128x128, make an output that is 64x64. You have done that.
(2) From the same input image, crop out an area 71x48+25+36, resize that to 34x24, and paste that over the output at offset 12,16.
Is that what you want?
(2) could be:
Adjust syntax as needed for your shell.
(1) From an input image that is 128x128, make an output that is 64x64. You have done that.
(2) From the same input image, crop out an area 71x48+25+36, resize that to 34x24, and paste that over the output at offset 12,16.
Is that what you want?
(2) could be:
Code: Select all
convert output.dds ( input.dds -crop 71x48+25+36 +repage ) -geometry 12,16 -compose Over -composite output.dds
snibgo's IM pages: im.snibgo.com
Re: Need help with copy pixels - resize and paste into another region
Hello snibgo,
yes thats what i want to do
All seems clear to me except where you resize the image to 34x24....?
yes thats what i want to do
All seems clear to me except where you resize the image to 34x24....?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Need help with copy pixels - resize and paste into another region
Sorry, yes, I forgot the resize.
If the two converts do what you want, you can then combine them into a single convert.
Code: Select all
convert output.dds ( input.dds -crop 71x48+25+36 +repage -resize 34x24 ) -geometry 12,16 -compose Over -composite output.dds
snibgo's IM pages: im.snibgo.com
Re: Need help with copy pixels - resize and paste into another region
Hi snibgo,
i am working on a windows desktop with win7
At first i had problems with directorys with spaces in it, so i changed to directorys without spaces in the names.
Now all worked until your code^^.
Here is the batchfile i am using:
The batchfile works until the convert inside the convert....
Maybe a syntax error?
Thanks for help
Avanatus
i am working on a windows desktop with win7
At first i had problems with directorys with spaces in it, so i changed to directorys without spaces in the names.
Now all worked until your code^^.
Here is the batchfile i am using:
Code: Select all
del tempimage1\*.dds
del tempimage2\*.dds
del tempimage3\*.dds
del outputimage1\*.dds
:: Batchfile for ImageMagick - by ava 06072016
:: Converting DDS files from 128x128 into 64x64 DDS Files and replacing the position
::Turn of displaying the code on the screen
@echo on
:: Read all the dds images from the directory, resize them, and save as a dds in a different directory
setLocal ENABLEDELAYEDEXPANSION
SET IMCONV="%PROGRAMFILES%\ImageMagick"
CD %~p1
for %%f in (*.dds) do (
set filename=%%~nf
set filepath=%%~pf
convert "%%f" -crop 71x48+25+36 -define dds:compression=none "!filepath!tempimage1\!filename!.dds"
)
cd tempimage1
for %%f in (*.dds) do (
set filename=%%~nf
convert "%%f" -resize 34x24 -define dds:compression=none "!filepath!tempimage2\!filename!.dds"
)
cd..
for %%f in (*.dds) do (
set filename=%%~nf
convert "%%f" -alpha transparent -resize 64x64 -define dds:compression=none "!filepath!tempimage3\!filename!.dds"
)
cd tempimage3
for %%f in (*.dds) do (
set filename=%%~nf
convert "%%f" ( "!filepath!\!filename!.dds" -crop 71x48+25+36 +repage -resize 34x24 ) -geometry 12,16 -compose Over -composite "!filepath!outputimage1\!filename!.dds"
)
:: -define dds:compression={dxt1, dxt5, none}
endlocal
pause
Maybe a syntax error?
Thanks for help
Avanatus
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Need help with copy pixels - resize and paste into another region
When your command contains parentheses ( and ) within a "for" if "if" parentheses, you need to escape them.
Code: Select all
convert "%%f" ^( "!filepath!\!filename!.dds" -crop 71x48+25+36 +repage -resize 34x24 ^) -geometry 12,16 -compose Over -composite "!filepath!outputimage1\!filename!.dds"
snibgo's IM pages: im.snibgo.com
Re: Need help with copy pixels - resize and paste into another region
Thanks snibgo - it helps....
Now i get an error from the convert module "convert: invalid geometry `12,16' @ error/geometry.c/ParseRegionGeometry/1542."
Hmpf^^
Now i get an error from the convert module "convert: invalid geometry `12,16' @ error/geometry.c/ParseRegionGeometry/1542."
Hmpf^^
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Need help with copy pixels - resize and paste into another region
See the manual at http://www.imagemagick.org/script/comma ... p#geometry and follow the link. It gives you the required syntax.
snibgo's IM pages: im.snibgo.com
Re: Need help with copy pixels - resize and paste into another region
Ahh... thanks
Forgot the + sighns^^
now:
...works like a charm^^
Thanks a million for help
Avanatus
Forgot the + sighns^^
now:
Code: Select all
convert "%%f" ^( "!filepath!\!filename!.dds" -crop 71x48+25+36 +repage -resize 34x24 ^) -geometry +12+16 -compose Over -composite "!filepath!outputimage1\!filename!.dds"
)
Thanks a million for help
Avanatus
Re: Need help with copy pixels - resize and paste into another region
How can i set the thread to "solved"?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Need help with copy pixels - resize and paste into another region
Edit the title of your very first (top) post in this thread.Avanatus wrote:How can i set the thread to "solved"?
Re: [solved] Need help with copy pixels - resize and paste into another region
Done - and thanks for help