eliminating extra space
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
eliminating extra space
Dear friends
in a command where i make a perspective distorsion over another image, extra white space is created in the resulting image,
how can i eliminate it within the same original command?
$command= 'convert '.$source1.' ( '.$source.' -matte -virtual-pixel transparent -distort Perspective "'.$points.'" ) (more stuff here ) -compose over -layers merge '.$target2;
passthru($command);
thanks very much
jav
in a command where i make a perspective distorsion over another image, extra white space is created in the resulting image,
how can i eliminate it within the same original command?
$command= 'convert '.$source1.' ( '.$source.' -matte -virtual-pixel transparent -distort Perspective "'.$points.'" ) (more stuff here ) -compose over -layers merge '.$target2;
passthru($command);
thanks very much
jav
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
Re: eliminating extra space
seems that i can do it by adding at the end
-extent $finalwidthx$finalheight
that seems to work, is that the best way to reduce the final size to the desired one?
thank u very much
jav
-extent $finalwidthx$finalheight
that seems to work, is that the best way to reduce the final size to the desired one?
thank u very much
jav
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
Re: eliminating extra space
i can now explain better my confusion
lets say my image has dimensions 680x952
if i use these points in perspective distorsion
$p1="0,0";$p2="680,0";$p3="680,952";$p4="0,952";
$w1="0,0";$w2="680,0";$w3="680,952";$w4="0,952";
i get no changes of course, image looks nice as it is
if i now do
$w1="100,0";$w2="780,0";$w3="680,952";$w4="0,952";
the two top points should displace to the right
and in fact they do
but the right part gets cropped by the right edge of the image itself!!!
this is the problem i have
because im using a single command to compose it all together, i dont understand why is it getting cropped like that
im using this overall command
$command= 'convert '.$base.' ( '.$source.' -matte -virtual-pixel transparent -distort Perspective "'.$points.'" ) ( '.$source2.' -matte -virtual-pixel transparent ) -compose over -layers merge '.$target2;
any help please?
problem is that any displacement of $source with the $points, gets cropped by the boundaries and edges of $source itself,
this is not good as i need to distort $source within the overall space of $base
thanks so very much
Jav
lets say my image has dimensions 680x952
if i use these points in perspective distorsion
$p1="0,0";$p2="680,0";$p3="680,952";$p4="0,952";
$w1="0,0";$w2="680,0";$w3="680,952";$w4="0,952";
i get no changes of course, image looks nice as it is
if i now do
$w1="100,0";$w2="780,0";$w3="680,952";$w4="0,952";
the two top points should displace to the right
and in fact they do
but the right part gets cropped by the right edge of the image itself!!!
this is the problem i have
because im using a single command to compose it all together, i dont understand why is it getting cropped like that
im using this overall command
$command= 'convert '.$base.' ( '.$source.' -matte -virtual-pixel transparent -distort Perspective "'.$points.'" ) ( '.$source2.' -matte -virtual-pixel transparent ) -compose over -layers merge '.$target2;
any help please?
problem is that any displacement of $source with the $points, gets cropped by the boundaries and edges of $source itself,
this is not good as i need to distort $source within the overall space of $base
thanks so very much
Jav
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: eliminating extra space
yes, but one usually adds -gravity XX and -background somecolor to specify where the extent should take place and the fill color. see http://www.imagemagick.org/Usage/crop/#extent
however, if the image is going to be smaller then the you just need to use
-gravity XX -crop ${width}x${height}+0+0 +repage
however, if the image is going to be smaller then the you just need to use
-gravity XX -crop ${width}x${height}+0+0 +repage
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
Re: eliminating extra space
i just saw this by Anthony
so should i use + distort instead of -distort? i tried but nothing seemed to happen,
and how do i "specifying a expert 'viewport' setting you want to use to 'view' the distorted space" ?
i can see that i need some way of telling the system to apply the distort within a larger space beyond the boundaries of the image
basically my background lets say is 1000x500, and my image to be distorted is 600x300 ,
when i distort the 600x300 image i need it to be able to go beyond its own 600x300 boundaries
__________
Basically -distort distorts images using the original image as the 'viewport' boundaries for the distortion.
Input can be virtual, though generally isn't, as such the distorted image will be cropped but the original images bounds.
Some exceptions to this are the 'Polar' distortions as the image size really needs to change to hold any 'practical' result.
But the new bounds are chosen to be a normal non-layered (no virtual offset) image
+distort however attempts to calculate virtual canvas viewport bounds according to the distortion so as to try and hold ALL the results. That includes some of the fuzzy edge pixels caused by the filter (though that is only a rough adjustment).
This is not always easy as for some distortions as it not only needs the 'reverse map' function used for the actual distort, but alos a forward map function, to find the limits of the distortion. Because of this some distorts can calculate appropriate bounds for +distort, For example "Shepards Distortion".
However you can override BOTH techniques by specifying a expert 'viewport' setting you want to use to 'view' the distorted space.
"
so should i use + distort instead of -distort? i tried but nothing seemed to happen,
and how do i "specifying a expert 'viewport' setting you want to use to 'view' the distorted space" ?
i can see that i need some way of telling the system to apply the distort within a larger space beyond the boundaries of the image
basically my background lets say is 1000x500, and my image to be distorted is 600x300 ,
when i distort the 600x300 image i need it to be able to go beyond its own 600x300 boundaries
__________
Basically -distort distorts images using the original image as the 'viewport' boundaries for the distortion.
Input can be virtual, though generally isn't, as such the distorted image will be cropped but the original images bounds.
Some exceptions to this are the 'Polar' distortions as the image size really needs to change to hold any 'practical' result.
But the new bounds are chosen to be a normal non-layered (no virtual offset) image
+distort however attempts to calculate virtual canvas viewport bounds according to the distortion so as to try and hold ALL the results. That includes some of the fuzzy edge pixels caused by the filter (though that is only a rough adjustment).
This is not always easy as for some distortions as it not only needs the 'reverse map' function used for the actual distort, but alos a forward map function, to find the limits of the distortion. Because of this some distorts can calculate appropriate bounds for +distort, For example "Shepards Distortion".
However you can override BOTH techniques by specifying a expert 'viewport' setting you want to use to 'view' the distorted space.
"
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
Re: eliminating extra space
thank u very much Fred
the extent is working already, not a problem anymore
the big problem i have now is that the image im distorting is being cropped by its own boundaries,
im trying to understand anthony's explanation of how to allow the distortion to go beyond the image's own boundaries,
do u know how?
i put anthony's text on my previous message
thank u thank u
the extent is working already, not a problem anymore
the big problem i have now is that the image im distorting is being cropped by its own boundaries,
im trying to understand anthony's explanation of how to allow the distortion to go beyond the image's own boundaries,
do u know how?
i put anthony's text on my previous message
thank u thank u
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
Re: eliminating extra space
ahaaa
i see that +distort seems to work now, mmm , nice
what about the alternative anthony says? the
"However you can override BOTH techniques by specifying a expert 'viewport' setting you want to use to 'view' the distorted space."
i would like to do that, sounds like the best of it all
smiles
i see that +distort seems to work now, mmm , nice
what about the alternative anthony says? the
"However you can override BOTH techniques by specifying a expert 'viewport' setting you want to use to 'view' the distorted space."
i would like to do that, sounds like the best of it all
smiles
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: eliminating extra space
use +distort that will allow the canvas to expand to fill the image
try a simple example and if that does not work, give us the command line you use with the exact coordinates you are using and perhaps post a link to your input image.
try a simple example and if that does not work, give us the command line you use with the exact coordinates you are using and perhaps post a link to your input image.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: eliminating extra space
see http://www.imagemagick.org/Usage/distor ... t_viewport
but get one thing understood before moving to another. don't try them both together until you understand +distort
for doing both, see the rotation example at http://www.imagemagick.org/Usage/distor ... te_methods
but get one thing understood before moving to another. don't try them both together until you understand +distort
for doing both, see the rotation example at http://www.imagemagick.org/Usage/distor ... te_methods
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
Re: eliminating extra space
thank u very much Fred
+ distort seems to work, i just tried it, all i did was to change
-distort to +distort and it works, seems to work,
are there are differences in performance between using +distort and using the viewport solution?
i will now check your link of the viewport solution
+ distort seems to work, i just tried it, all i did was to change
-distort to +distort and it works, seems to work,
are there are differences in performance between using +distort and using the viewport solution?
i will now check your link of the viewport solution
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
Re: eliminating extra space
aha i see, very nice the "-define distort:viewport=125x125-25-25 "
this looks great, so the question now is
in terms of performance what is faster?
to use +distort ?
or to use -define distort:viewport=125x125-25-25 ?
this looks great, so the question now is
in terms of performance what is faster?
to use +distort ?
or to use -define distort:viewport=125x125-25-25 ?
-
- Posts: 180
- Joined: 2010-11-27T01:42:06-07:00
- Authentication code: 8675308
Re: eliminating extra space
by the way, i believe in recognizing good things when i see them,
and i have to say again, i have never in my life seen a forum that works as well as this one, i think the work Anthony and you are doing helping
people here is extraordinary, you guys always answer so fast and so well, im really amazed, havent had this experience in any other forum anywhere in relation to any other topic, so you guys deserve recognition really for this, thank u very much, be sure that people like me deeply appreciate what you are doing
best
jav
and i have to say again, i have never in my life seen a forum that works as well as this one, i think the work Anthony and you are doing helping
people here is extraordinary, you guys always answer so fast and so well, im really amazed, havent had this experience in any other forum anywhere in relation to any other topic, so you guys deserve recognition really for this, thank u very much, be sure that people like me deeply appreciate what you are doing
best
jav
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: eliminating extra space
it depends upon what you are doing. if all you need is to crop, then you should just use -crop. if you need to distort then use +distort and it will give you the full size. however, if you only want part of the full size, then use both together.in terms of performance what is faster?
to use +distort ?
or to use -define distort:viewport=125x125-25-25
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: eliminating extra space
Speed is a function of size of output image (the viewport size), and if the compression is reaching near infinities,javismiles wrote:aha i see, very nice the "-define distort:viewport=125x125-25-25 "
this looks great, so the question now is
in terms of performance what is faster?
to use +distort ?
or to use -define distort:viewport=125x125-25-25 ?
such as when viewing distant horizons. Boith can be made faster by turning or EWA (using -filter point) but if you do that any compression stronger than 2 times will become strongly aliased.
See the examples (with relative timings) in
Area Resampling
http://www.imagemagick.org/Usage/distor ... a_resample
If viewing distant horizons without tiling virtual pixel effect, it is generally not a problem.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/