By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,270 Members | 1,582 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,270 IT Pros & Developers. It's quick & easy.

getting image size next....

P: n/a
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height
of my webcontrol based on the image height.
More i just have the url (relative parth) to the the image but in design
time mode all variables concerning Server or Context
ar not set ! ...so I can't use MapPath function to obtain the physical
parth of the picture ...

So my second question is how to retrieve the
physical root path of the current application loaded in VS.NET (from
relative path) in Design Mode...

Thanks
Karim
Nov 18 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
read the image into a memory stream
load it into a System.Drawing.Image object
once you do that you can find the height and width etc of the image

hope this helps

--
Regards,
HD
Once a Geek.... Always a Geek
"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height
of my webcontrol based on the image height.
More i just have the url (relative parth) to the the image but in design
time mode all variables concerning Server or Context
ar not set ! ...so I can't use MapPath function to obtain the physical
parth of the picture ...

So my second question is how to retrieve the
physical root path of the current application loaded in VS.NET (from
relative path) in Design Mode...

Thanks
Karim

Nov 18 '05 #2

P: n/a
You find the file in windows explorer, right click, properties, and look at
the location? I'm sorry I don't know if I'm understanding you, because
getting the physical path should be a pretty trivial task.

--Michael

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height
of my webcontrol based on the image height.
More i just have the url (relative parth) to the the image but in design
time mode all variables concerning Server or Context
ar not set ! ...so I can't use MapPath function to obtain the physical
parth of the picture ...

So my second question is how to retrieve the
physical root path of the current application loaded in VS.NET (from
relative path) in Design Mode...

Thanks
Karim

Nov 18 '05 #3

P: n/a
yes it could but it's a composite webcontrol
that embeds an image control and on of its properties is the url of the
image...
so at design time it pops the ImageUrlEditor, i keep the resulting string
value in a string and from
this string I try to get the size...
but there's no way to get the image size with this image component... so
other solution is my question below....

Karim

"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
You find the file in windows explorer, right click, properties, and look at the location? I'm sorry I don't know if I'm understanding you, because
getting the physical path should be a pretty trivial task.

--Michael

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height of my webcontrol based on the image height.
More i just have the url (relative parth) to the the image but in design
time mode all variables concerning Server or Context
ar not set ! ...so I can't use MapPath function to obtain the physical
parth of the picture ...

So my second question is how to retrieve the
physical root path of the current application loaded in VS.NET (from
relative path) in Design Mode...

Thanks
Karim


Nov 18 '05 #4

P: n/a
He's right. He's looking to use a relative path during design time.
Unfortunately, everything I found says .NET neglected to provide design-time
relative path methods / properties. Personally, I ended up writing my own 2
global properties as below.

As for the image size, I can't help you there. System.Drawing.Image sounds
like a good way to start, though.

Hope this helps!
Sam
public static bool DesignMode
{
get
{
return (HttpContext.Current == null);
}
}

public static string ApplicationPath
{
get
{
if (!DesignMode)
{
string currentpath = HttpContext.Current.Request.ApplicationPath;
if (currentpath.Substring(currentpath.Length) != "/") currentpath +=
"/";
return currentpath;
}
else
{
return "file://path to application root/";
}
}
}
"Michael Ramey" <raterus@localhost> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You find the file in windows explorer, right click, properties, and look at the location? I'm sorry I don't know if I'm understanding you, because
getting the physical path should be a pretty trivial task.

--Michael

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height of my webcontrol based on the image height.
More i just have the url (relative parth) to the the image but in design
time mode all variables concerning Server or Context
ar not set ! ...so I can't use MapPath function to obtain the physical
parth of the picture ...

So my second question is how to retrieve the
physical root path of the current application loaded in VS.NET (from
relative path) in Design Mode...

Thanks
Karim


Nov 18 '05 #5

P: n/a
Do you care if at design time you can actually see the image on your
designer? If you don't just put the relative path. It'll probably give you
a big x (or whatever it does), to state it doesn't know where that file is,
but at runtime, you can grap the location, do a server.mappath, and you
should be good to go with getting the image size.

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
yes it could but it's a composite webcontrol
that embeds an image control and on of its properties is the url of the
image...
so at design time it pops the ImageUrlEditor, i keep the resulting string
value in a string and from
this string I try to get the size...
but there's no way to get the image size with this image component... so
other solution is my question below....

Karim

"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
You find the file in windows explorer, right click, properties, and look

at
the location? I'm sorry I don't know if I'm understanding you, because
getting the physical path should be a pretty trivial task.

--Michael

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height of my webcontrol based on the image height.
More i just have the url (relative parth) to the the image but in design time mode all variables concerning Server or Context
ar not set ! ...so I can't use MapPath function to obtain the physical
parth of the picture ...

So my second question is how to retrieve the
physical root path of the current application loaded in VS.NET (from
relative path) in Design Mode...

Thanks
Karim



Nov 18 '05 #6

P: n/a
if he's so fixed up on wanting the size... then he should read it into a
stream and load it into System.Drawing,Image
then they can all the data he wants... (considering that the custom control
will be Rendered even in design mode in the application)

--
Regards,
HD
Once a Geek.... Always a Geek
"Michael Ramey" <raterus@localhost> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...
Do you care if at design time you can actually see the image on your
designer? If you don't just put the relative path. It'll probably give
you
a big x (or whatever it does), to state it doesn't know where that file
is,
but at runtime, you can grap the location, do a server.mappath, and you
should be good to go with getting the image size.

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
yes it could but it's a composite webcontrol
that embeds an image control and on of its properties is the url of the
image...
so at design time it pops the ImageUrlEditor, i keep the resulting string
value in a string and from
this string I try to get the size...
but there's no way to get the image size with this image component... so
other solution is my question below....

Karim

"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
> You find the file in windows explorer, right click, properties, and
> look

at
> the location? I'm sorry I don't know if I'm understanding you, because
> getting the physical path should be a pretty trivial task.
>
> --Michael
>
> "KarimL" <no*****************@free.fr> wrote in message
> news:bv***********@biggoron.nerim.net...
> > Thanks for your advices...
> > but i need to get the Image height because i dynamically resize the

height
> > of my webcontrol based on the image height.
> > More i just have the url (relative parth) to the the image but in design > > time mode all variables concerning Server or Context
> > ar not set ! ...so I can't use MapPath function to obtain the
> > physical
> > parth of the picture ...
> >
> > So my second question is how to retrieve the
> > physical root path of the current application loaded in VS.NET (from
> > relative path) in Design Mode...
> >
> > Thanks
> > Karim
> >
> >
>
>



Nov 18 '05 #7

P: n/a
Thanks Michael...
but for runtime all variables are instanciated (Server,context...) but my
problem is specific
to design time.... i seek a solution to get the image size :
a global function to translate the relative path to physical path
or
a way to retrieve the current loaded project in the VS.NET and it's
physical root path
.....

Karim
"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:ud**************@TK2MSFTNGP09.phx.gbl...
Do you care if at design time you can actually see the image on your
designer? If you don't just put the relative path. It'll probably give you a big x (or whatever it does), to state it doesn't know where that file is, but at runtime, you can grap the location, do a server.mappath, and you
should be good to go with getting the image size.

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
yes it could but it's a composite webcontrol
that embeds an image control and on of its properties is the url of the
image...
so at design time it pops the ImageUrlEditor, i keep the resulting string
value in a string and from
this string I try to get the size...
but there's no way to get the image size with this image component... so
other solution is my question below....

Karim

"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
You find the file in windows explorer, right click, properties, and look
at
the location? I'm sorry I don't know if I'm understanding you,

because getting the physical path should be a pretty trivial task.

--Michael

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
> Thanks for your advices...
> but i need to get the Image height because i dynamically resize the

height
> of my webcontrol based on the image height.
> More i just have the url (relative parth) to the the image but in

design > time mode all variables concerning Server or Context
> ar not set ! ...so I can't use MapPath function to obtain the physical > parth of the picture ...
>
> So my second question is how to retrieve the
> physical root path of the current application loaded in VS.NET (from
> relative path) in Design Mode...
>
> Thanks
> Karim
>
>



Nov 18 '05 #8

P: n/a
i tested System.Drawing,Image.FromFile(relative_path)
but it doesn't work either...

Karim

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> a écrit dans le
message de news:%2****************@TK2MSFTNGP11.phx.gbl...
if he's so fixed up on wanting the size... then he should read it into a
stream and load it into System.Drawing,Image
then they can all the data he wants... (considering that the custom control will be Rendered even in design mode in the application)

--
Regards,
HD
Once a Geek.... Always a Geek
"Michael Ramey" <raterus@localhost> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...
Do you care if at design time you can actually see the image on your
designer? If you don't just put the relative path. It'll probably give
you
a big x (or whatever it does), to state it doesn't know where that file
is,
but at runtime, you can grap the location, do a server.mappath, and you
should be good to go with getting the image size.

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
yes it could but it's a composite webcontrol
that embeds an image control and on of its properties is the url of the
image...
so at design time it pops the ImageUrlEditor, i keep the resulting string value in a string and from
this string I try to get the size...
but there's no way to get the image size with this image component... so other solution is my question below....

Karim

"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
> You find the file in windows explorer, right click, properties, and
> look
at
> the location? I'm sorry I don't know if I'm understanding you, because > getting the physical path should be a pretty trivial task.
>
> --Michael
>
> "KarimL" <no*****************@free.fr> wrote in message
> news:bv***********@biggoron.nerim.net...
> > Thanks for your advices...
> > but i need to get the Image height because i dynamically resize the
height
> > of my webcontrol based on the image height.
> > More i just have the url (relative parth) to the the image but in

design
> > time mode all variables concerning Server or Context
> > ar not set ! ...so I can't use MapPath function to obtain the
> > physical
> > parth of the picture ...
> >
> > So my second question is how to retrieve the
> > physical root path of the current application loaded in VS.NET (from > > relative path) in Design Mode...
> >
> > Thanks
> > Karim
> >
> >
>
>



Nov 18 '05 #9

P: n/a
well try the physical path.
since your object will be in memory and will be executed even in design
mode, i think you should be able to use
mappath to get the physical path. if not then hard code the application path
(web.config is a good place to start) and then at run time calculate the
exact physical path

--
Regards,
HD
Once a Geek.... Always a Geek
"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
i tested System.Drawing,Image.FromFile(relative_path)
but it doesn't work either...

Karim

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> a écrit dans le
message de news:%2****************@TK2MSFTNGP11.phx.gbl...
if he's so fixed up on wanting the size... then he should read it into a
stream and load it into System.Drawing,Image
then they can all the data he wants... (considering that the custom

control
will be Rendered even in design mode in the application)

--
Regards,
HD
Once a Geek.... Always a Geek
"Michael Ramey" <raterus@localhost> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...
> Do you care if at design time you can actually see the image on your
> designer? If you don't just put the relative path. It'll probably
> give
> you
> a big x (or whatever it does), to state it doesn't know where that file
> is,
> but at runtime, you can grap the location, do a server.mappath, and you
> should be good to go with getting the image size.
>
> "KarimL" <no*****************@free.fr> wrote in message
> news:bv***********@biggoron.nerim.net...
>> yes it could but it's a composite webcontrol
>> that embeds an image control and on of its properties is the url of
>> the
>> image...
>> so at design time it pops the ImageUrlEditor, i keep the resulting string >> value in a string and from
>> this string I try to get the size...
>> but there's no way to get the image size with this image component... so >> other solution is my question below....
>>
>> Karim
>>
>> "Michael Ramey" <raterus@localhost> a écrit dans le message de
>> news:%2****************@TK2MSFTNGP10.phx.gbl...
>> > You find the file in windows explorer, right click, properties, and
>> > look
>> at
>> > the location? I'm sorry I don't know if I'm understanding you, because >> > getting the physical path should be a pretty trivial task.
>> >
>> > --Michael
>> >
>> > "KarimL" <no*****************@free.fr> wrote in message
>> > news:bv***********@biggoron.nerim.net...
>> > > Thanks for your advices...
>> > > but i need to get the Image height because i dynamically resize
>> > > the
>> height
>> > > of my webcontrol based on the image height.
>> > > More i just have the url (relative parth) to the the image but in
> design
>> > > time mode all variables concerning Server or Context
>> > > ar not set ! ...so I can't use MapPath function to obtain the
>> > > physical
>> > > parth of the picture ...
>> > >
>> > > So my second question is how to retrieve the
>> > > physical root path of the current application loaded in VS.NET (from >> > > relative path) in Design Mode...
>> > >
>> > > Thanks
>> > > Karim
>> > >
>> > >
>> >
>> >
>>
>>
>
>



Nov 18 '05 #10

P: n/a
Could you write a string function, that takes in an absolute path (the one
you set at design time), hacks it to a relative path, then run
server.mappath() on it?

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
Thanks Michael...
but for runtime all variables are instanciated (Server,context...) but my
problem is specific
to design time.... i seek a solution to get the image size :
a global function to translate the relative path to physical path
or
a way to retrieve the current loaded project in the VS.NET and it's
physical root path
....

Karim
"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:ud**************@TK2MSFTNGP09.phx.gbl...
Do you care if at design time you can actually see the image on your
designer? If you don't just put the relative path. It'll probably give

you
a big x (or whatever it does), to state it doesn't know where that file

is,
but at runtime, you can grap the location, do a server.mappath, and you
should be good to go with getting the image size.

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
yes it could but it's a composite webcontrol
that embeds an image control and on of its properties is the url of the image...
so at design time it pops the ImageUrlEditor, i keep the resulting string value in a string and from
this string I try to get the size...
but there's no way to get the image size with this image component... so other solution is my question below....

Karim

"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
> You find the file in windows explorer, right click, properties, and look at
> the location? I'm sorry I don't know if I'm understanding you, because > getting the physical path should be a pretty trivial task.
>
> --Michael
>
> "KarimL" <no*****************@free.fr> wrote in message
> news:bv***********@biggoron.nerim.net...
> > Thanks for your advices...
> > but i need to get the Image height because i dynamically resize the height
> > of my webcontrol based on the image height.
> > More i just have the url (relative parth) to the the image but in

design
> > time mode all variables concerning Server or Context
> > ar not set ! ...so I can't use MapPath function to obtain the physical > > parth of the picture ...
> >
> > So my second question is how to retrieve the
> > physical root path of the current application loaded in VS.NET (from > > relative path) in Design Mode...
> >
> > Thanks
> > Karim
> >
> >
>
>



Nov 18 '05 #11

P: n/a
Yes I could... but this does not satisfies me....
i'm currently diving into VS.NET automation model ... I keep you informed if
i find something..

Karim

"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:eD*************@TK2MSFTNGP12.phx.gbl...
Could you write a string function, that takes in an absolute path (the one
you set at design time), hacks it to a relative path, then run
server.mappath() on it?

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
Thanks Michael...
but for runtime all variables are instanciated (Server,context...) but my
problem is specific
to design time.... i seek a solution to get the image size :
a global function to translate the relative path to physical path
or
a way to retrieve the current loaded project in the VS.NET and it's
physical root path
....

Karim
"Michael Ramey" <raterus@localhost> a écrit dans le message de
news:ud**************@TK2MSFTNGP09.phx.gbl...
Do you care if at design time you can actually see the image on your
designer? If you don't just put the relative path. It'll probably give
you
a big x (or whatever it does), to state it doesn't know where that
file is,
but at runtime, you can grap the location, do a server.mappath, and
you should be good to go with getting the image size.

"KarimL" <no*****************@free.fr> wrote in message
news:bv***********@biggoron.nerim.net...
> yes it could but it's a composite webcontrol
> that embeds an image control and on of its properties is the url of
the > image...
> so at design time it pops the ImageUrlEditor, i keep the resulting

string
> value in a string and from
> this string I try to get the size...
> but there's no way to get the image size with this image component... so
> other solution is my question below....
>
> Karim
>
> "Michael Ramey" <raterus@localhost> a écrit dans le message de
> news:%2****************@TK2MSFTNGP10.phx.gbl...
> > You find the file in windows explorer, right click, properties,
and look
> at
> > the location? I'm sorry I don't know if I'm understanding you,

because
> > getting the physical path should be a pretty trivial task.
> >
> > --Michael
> >
> > "KarimL" <no*****************@free.fr> wrote in message
> > news:bv***********@biggoron.nerim.net...
> > > Thanks for your advices...
> > > but i need to get the Image height because i dynamically resize

the > height
> > > of my webcontrol based on the image height.
> > > More i just have the url (relative parth) to the the image but
in design
> > > time mode all variables concerning Server or Context
> > > ar not set ! ...so I can't use MapPath function to obtain the

physical
> > > parth of the picture ...
> > >
> > > So my second question is how to retrieve the
> > > physical root path of the current application loaded in VS.NET

(from > > > relative path) in Design Mode...
> > >
> > > Thanks
> > > Karim
> > >
> > >
> >
> >
>
>



Nov 18 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.