image size 
Author Message
 image size
I have an image box that user can open an image on it. this image box has a
restricted size, so I must restrict the user to open an image with a
limitation in the image's size. I use an open dialog control. I know that
this control has a property to restrict the file's size that the user wants
to open, but I don't know what is it's unit?pixel? Kb? KB? how can I use this
property to restrict user's selection? for example if I want that the user's
selection be less that 300*200 pixel, what should I do?I examine it a lot,
but it doesn't work, what can I do?

thanks.



Thu, 09 Dec 2010 20:29:01 GMT  
 image size


Quote:
>I have an image box that user can open an image on it. this image box has a
> restricted size, so I must restrict the user to open an image with a
> limitation in the image's size. I use an open dialog control. I know that
> this control has a property to restrict the file's size that the user
> wants
> to open, but I don't know what is it's unit?pixel? Kb? KB? how can I use
> this
> property to restrict user's selection? for example if I want that the
> user's
> selection be less that 300*200 pixel, what should I do?I examine it a lot,
> but it doesn't work, what can I do?

By "open dialog control" do you mean the CommonDialog control's Open dialog
box? I'm not aware of anything in that dialog (built-in at least) that can
restrict a file to a certain size.  However, if it does, I'd guess it'd be
by file size (IOW, bytes or KB), which would be virtually useless for
restricting image size. My guess is you're simply going to have to let the
user choose the file, load it into a StdPicture object, and check it's
dimensions BEFORE assigning it to your Image control.

Something like this:

    Dim sFileName As String
    Dim oStdPic As StdPicture

    With CommonDialog1
        .Filter = "Picture Files|*.bmp;*.jpg;*.jpeg;*.gif"
        .ShowOpen
        sFileName = .FileName
    End With

    Set oStdPic = LoadPicture(sFileName)
    If (ScaleX(oStdPic.Width, vbHimetric, vbPixels) > 300) Or
(ScaleY(oStdPic.Height, vbHimetric, vbPixels) > 200) Then
        MsgBox "Image dimensions cannot exceed 300x200 pixels"
    Else
        Set Image1.Picture = oStdPic
    End If

--
Mike
Microsoft MVP Visual Basic



Thu, 09 Dec 2010 21:48:28 GMT  
 image size

Quote:



> >I have an image box that user can open an image on it. this image box has a
> > restricted size, so I must restrict the user to open an image with a
> > limitation in the image's size. I use an open dialog control. I know that
> > this control has a property to restrict the file's size that the user
> > wants
> > to open, but I don't know what is it's unit?pixel? Kb? KB? how can I use
> > this
> > property to restrict user's selection? for example if I want that the
> > user's
> > selection be less that 300*200 pixel, what should I do?I examine it a lot,
> > but it doesn't work, what can I do?

> By "open dialog control" do you mean the CommonDialog control's Open dialog
> box? I'm not aware of anything in that dialog (built-in at least) that can
> restrict a file to a certain size.  However, if it does, I'd guess it'd be
> by file size (IOW, bytes or KB), which would be virtually useless for
> restricting image size. My guess is you're simply going to have to let the
> user choose the file, load it into a StdPicture object, and check it's
> dimensions BEFORE assigning it to your Image control.

> Something like this:

>     Dim sFileName As String
>     Dim oStdPic As StdPicture

>     With CommonDialog1
>         .Filter = "Picture Files|*.bmp;*.jpg;*.jpeg;*.gif"
>         .ShowOpen
>         sFileName = .FileName
>     End With

>     Set oStdPic = LoadPicture(sFileName)
>     If (ScaleX(oStdPic.Width, vbHimetric, vbPixels) > 300) Or
> (ScaleY(oStdPic.Height, vbHimetric, vbPixels) > 200) Then
>         MsgBox "Image dimensions cannot exceed 300x200 pixels"
>     Else
>         Set Image1.Picture = oStdPic
>     End If

> --
> Mike
> Microsoft MVP Visual Basic

thanks a lot for your help.


Fri, 10 Dec 2010 14:33:00 GMT  
 image size

Quote:
> I have an image box that user can open an image on it. this image box has
a
> restricted size, so I must restrict the user to open an image with a
> limitation in the image's size. I use an open dialog control. I know that
> this control has a property to restrict the file's size that the user
wants
> to open, but I don't know what is it's unit?pixel? Kb? KB? how can I use
this
> property to restrict user's selection? for example if I want that the
user's
> selection be less that 300*200 pixel, what should I do?I examine it a lot,
> but it doesn't work, what can I do?

Nothing automatic using the OCX.  You'd have to impliment your dialog via
API, using its hook (callback) capabilities to "redirect" to your
restrictions proceedure.


Fri, 10 Dec 2010 14:47:35 GMT  
 image size

Quote:
> I have an image box that user can open an image on it.
> this image box has a restricted size, so I must restrict the
> user to open an image with a limitation in the image's size.

Why? Why not just allow the user to open an image file of whatever pixel
size he wishes and display it on the screen at your desired size, which can
be just about any size you wish. That's the standard way of doing these
things. Is there some specific reason why you cannot deal with images of a
large pixel size?

Mike



Fri, 10 Dec 2010 15:59:21 GMT  
 image size

Quote:



> > I have an image box that user can open an image on it.
> > this image box has a restricted size, so I must restrict the
> > user to open an image with a limitation in the image's size.

> Why? Why not just allow the user to open an image file of whatever pixel
> size he wishes and display it on the screen at your desired size, which can
> be just about any size you wish. That's the standard way of doing these
> things. Is there some specific reason why you cannot deal with images of a
> large pixel size?

> Mike

I want to use that image in a database field, so I have some limitation in
the image size, and I should restrict the file size.
thanks for your attention, I used the MikeD reply, it worked.


Fri, 10 Dec 2010 19:19:00 GMT  
 image size

Quote:
>> [Mike wrote] Why? Why not just allow the user to open an image
>> file of whatever pixel size he wishes and display it on the screen at
>> your desired size, which can be just about any size you wish. That's
>> the standard way of doing these things. Is there some specific reason
>> why you cannot deal with images of a large pixel size?

> [F.N.Z. said] I want to use that image in a database field, so I have
> some limitation in the image size, and I should restrict the file size.
> thanks for your attention, I used the MikeD reply, it worked.

Yes, but Mike D was providing you with an answer to the specific question
you asked, whereas I was providing you with an answer to the question that
you could have asked, but did not ask ;-)

I still think that restricting the images a user can load depending on
either their file size or their pixel  size is a limitation that you really
should not be placing on your users, and I still say that you should allow
the user to load in images of whatever size they wish. Placing such
restrictions on your users is never a good idea.

You can write VB code to display the image on the screen at whatever size
you want, regardless of the pixel size of the original image loaded from
disk, and you can also write code to reduce the actual pixel size of a
loaded image to some other more suitable (and smaller) pixel size that would
be suitable for inclusion in your database, either as bitmaps or as jpegs.
So you can, for example, allow your user to load in a 1600 x 1200 pixel bmp
or jpeg or whatever and then reduce the pixel size (and, of course, the file
size) of that image to 320 x 240 pixels, or whatever size suits your
purposes.

To be perfectly honest, if I were using a program that allowed me to load
images into a database of some sort and if that program refused to allow me
to load photos from my camera (or whatever) purely because allowing me to do
so would cause some work for the author of the program then it would not be
very long before that application ended up in by trash can.

The user is King, and programmers who forget that do so at their peril  ;-)

Mike



Sat, 11 Dec 2010 00:26:29 GMT  
 image size


Quote:

> Yes, but Mike D was providing you with an answer to the specific question
> you asked, whereas I was providing you with an answer to the question that
> you could have asked, but did not ask ;-)

Maybe because it didn't need asking.  <g>

Quote:

> I still think that restricting the images a user can load depending on
> either their file size or their pixel  size is a limitation that you
> really should not be placing on your users, and I still say that you
> should allow the user to load in images of whatever size they wish.
> Placing such restrictions on your users is never a good idea.

> You can write VB code to display the image on the screen at whatever size
> you want, regardless of the pixel size of the original image loaded from
> disk, and you can also write code to reduce the actual pixel size of a
> loaded image to some other more suitable (and smaller) pixel size that
> would be suitable for inclusion in your database, either as bitmaps or as
> jpegs. So you can, for example, allow your user to load in a 1600 x 1200
> pixel bmp or jpeg or whatever and then reduce the pixel size (and, of
> course, the file size) of that image to 320 x 240 pixels, or whatever size
> suits your purposes.

> To be perfectly honest, if I were using a program that allowed me to load
> images into a database of some sort and if that program refused to allow
> me to load photos from my camera (or whatever) purely because allowing me
> to do so would cause some work for the author of the program then it would
> not be very long before that application ended up in by trash can.

No offense, Mike, but I kinda doubt you know his program, his requirements,
and his users. I mean, you don't even know that it's photos he's loading.
And IMO, if it IS perchance photos, then it's probably better to store the
path and file name in the database. Then again, maybe his program is for
archiving and the photo files will be deleted. See?  Don't have enough
information about the program (but I agree 100% that IF the program is for
archiving, it would indeed be very bad to restrict it to only archiving
images that are 300x200 or smaller).

There could be other reasons too he wants to limit to 300x200.  There might
be size restraints on how large the database can get (for whatever reason)
or perhaps larger images simply don't suit the application and its purpose
(again, for whatever reason).

I don't think there's anything wrong with you having brought this up because
maybe you provided points he didn't think of. I just don't think you, I, or
anyone else except F.N.Z can speculate about it and say he has to allow
larger sized images or his program sucks (and that's basically what you're
saying, at least that's how I took it).

--
Mike
Microsoft MVP Visual Basic



Sat, 11 Dec 2010 08:39:05 GMT  
 image size

Quote:
> No offense, Mike, but I kinda doubt you know his program, his
> requirements, and his users. I mean, you don't even know that
> it's photos he's loading.

Nope. It could be images of any kind. It doesn't matter one jot to me
whether it is photos or not. But I did actually ask him why he could not
load images over his suggested 320 x 200 pixel limit and he said, "I want to
use that image in a database field, so I have some limitation in the image
size". He did not say how he was actually storing those images in the
database, and he did not actually say exactly why the images needed to be of
a specific maximum size. I therefore suggested that he might wish to
consider allowing the user to load images of any size he wishes, and for his
VB program to automatically convert them to images of a size suitable for
inclusion in his database. It is something that the OP might not have
thought about, which is why I half jokingly said I was "answering a question
that he had not actually asked". But if you think I should not have made
that suggestion or answered that unasked question then that's fine. I'll
still carry on doing it though ;-)

Personally, notwithstanding the fact that the OP has not given us any
detailed information about his project or his customer base, I stand by my
earlier remarks that if I were to personally use a program that allowed me
to load images and if that program failed to allow me to load an image
larger than 320 x 200 pixels (or, indeed, larger than 1600 x 1200 pixels)
then that program would end up in my trash can. If I am allowed to load an
image of 320 x 200 pixels then surely I should be allowed to load a larger
pixel size image and have the program perform the appropriate conversion for
me. It seems a perfectly sensible thing to me.

Quote:
> And IMO, if it IS perchance photos, then it's probably better
> to store the path and file name in the database.

It probably is, or possibly it is not. Much depends of the exact nature of
the database and the use to which it is to be put.

Quote:
> Then again, maybe his program is for archiving and the
> photo files will be deleted. See?  Don't have enough information about the
> program

The fact that we don't have enough information about the program should not
prevent us from offering suitable alternative suggestions which the OP might
not have himself considered, which is exactly what I did.

Quote:
> There could be other reasons too he wants to limit to
> 300x200.  There might be size restraints on how large
> the database can get (for whatever reason)

There certainly could be, which is exactly why the OP should consider my own
suggestion of allowing the user to load whatever size images he wishes and
for the OP's program to perform the necessary conversion to an image no
larger than 320 x 200 pixels, or whatever. I really cannot see why you
appear to be "knocking" it? Seems to me to be a perfectly sensible
suggestion, especially in light of the fact that we do not have full details
of the OP's project or of his customer base :-)

Quote:
> or perhaps larger images simply don't suit the
> application and its purpose (again, for whatever reason).

Perhaps so, in which case what's wrong with making them smaller?

Quote:
> I don't think there's anything wrong with you having brought this
> up because maybe you provided points he didn't think of.

Ah . . . at last!

Quote:
> I just don't think you, I, or anyone else except F.N.Z can
> speculate about it and say he has to allow larger sized images
> or his program sucks

I did NOT say he "has to"! I said that if I was personally using a program
that allowed me to load images and if that program prevented me from loading
larger size images for some reason of its own and yet offered me no inbuilt
way of having their size reduced to suit whatever the requirements of that
program were then I would personally dump it into the trash can! He does not
have to do it. He can do whatever he likes. I'm just telling him what I
would do with his program in such a case, mostly because of the fact that he
appeared to "poo poo" my own suggestion without giving me a real answer to
my question when I asked him why his program had such an image size
restriction, other than to tell me that he wants to use that image in a
database field, which of course is not really an answer!

Quote:
> . . . saying he has to allow larger sized
> images or his program sucks

I didn't say his program sucks. You've just made that up! Perhaps you think
it sucks? I told him what I personally would do with it if it placed such
restrictions on me, and to be honest I still cannot see why the OP appeared
to "poo poo" my suggestion about allowing the user to load large images and
displaying them (and of course converting them) to smaller pixel size images
to suit his apparent database limitations. He has still not told us why he
apparently does not wish to do that.

Mike



Sat, 11 Dec 2010 20:43:28 GMT  
 image size

Quote:

>> . . . saying he has to allow larger sized
>> images or his program sucks

> I didn't say his program sucks. You've just made that up!

No I didn't. I inferred it from your comment "it would not be very long before that application ended up in by trash can".

Quote:
> Perhaps you think it sucks?

I don't know enough about the program to even have an opinion on it.

Quote:
> I told him what I personally would do with it if it placed such restrictions on me

And from that, one can infer that, in your opinion, the program sucks.

Quote:
> , and to be honest I still cannot see why the OP appeared to "poo poo" my suggestion about allowing the user to load large images
> and displaying them (and of course converting them) to smaller pixel size images to suit his apparent database limitations. He has
> still not told us why he apparently does not wish to do that.

No he hasn't. But that's really not relevant..at least I don't think so.  You made the point and he doesn't want to resize images.
'Nuff said.

--
Mike
Microsoft Visual Basic MVP



Sat, 11 Dec 2010 22:10:31 GMT  
 image size

Quote:
> No he hasn't. But that's really not relevant..at least I don't
> think so.  You made the point and he doesn't want to resize
> images. 'Nuff said.

No. That is NOT true. You are making things up again! The OP has NEVER in
this thread said that he does not want to resize images. Why do you insist
on repeatedly making things up in order to attempt to gain some undeserved
brownie points?

I initially suggested that he could open an image of any pixel size and that
he could display that image on the screen at any other smaller size he
wished, and he replied that he did not want to do that because of the
limitation of his database regarding image size and file size and that he
was happy to use the code you posted, which of course simple rejects images
over a certain pixel size.

So, the OP has merely said that he does not wish to reduce the *displayed
size* of a larger image, and in my opinion he was (at least at that point in
time) unaware of the fact that it was also possible to write code to reduce
the actual pixel size and the file size of the image to a size that is
definitely suitable for inclusion in his database, regardless of the
original pixel size or file size of the loaded image.

Then, in a later message, I told the OP that in addition to merely
displaying the image on the screen at whatever size he wished he could also
write VB code to reduce the actual pixel size (and of course the file size)
of a loaded image to some other more suitable (and smaller) pixel size that
would be suitable for inclusion in his database, either as bitmaps or as
jpegs. The OP has NOT yet responded to my suggestion, and so we as yet have
no idea whether or not he is prepared to reduce both the pixel size and the
file size of his images in code, hence it would be wise for you to resist
making things up about it until we know his answer to that one!

Again, as you have pointed out, the OP has not yet given us sufficient
details of his application or of his requirements to enable us to know for
certain what he is up to, but I reckon it is quite likely that he is writing
some sort of database program that stores information about employees and
that such information includes a photo, and that he wishes the photo to be
kept to a fairly low pixel size and file size. In that case, or in many
similar cases, my own suggestion of allowing the user to load a photo of any
original pixel or file size and of reducing both the pixel size and the file
size of the image in code is a perfectly reasonable suggestion.

Why do you keep insisting that the OP is not willing to reduce the pixel
size or the file size of images by making up things about the OP that he has
not actually said? Do you have a problem "living in a thread" in which
people other than yourself are providing possible answers, some of which you
may not have thought of yourself?

If the OP posts back and clearly states that he does not want to use code to
reduce both the pixel size and the file size of a large loaded image then
that's fine. It is up to him after all. But until he does so I will stand by
by suggestion that he should consider it, and in any case I will definitely
stand by my statement that failing to do so is placing totally unnecessary
restrictions on his application.

Mike



Sun, 12 Dec 2010 03:22:00 GMT  
 image size


Quote:


>> No he hasn't. But that's really not relevant..at least I don't
>> think so.  You made the point and he doesn't want to resize
>> images. 'Nuff said.

> No. That is NOT true. You are making things up again! The OP has NEVER in
> this thread said that he does not want to resize images. Why do you insist
> on repeatedly making things up in order to attempt to gain some undeserved
> brownie points?

He has made it quite clear that it's not desirable to say the least. It
doesn't need to be spelled out to figure that.

You're taking things much too personally...again. I even originally stated
that I thought it was good that you pointed out resizing the image as an
option. I just thought you were making TOO much an issue of it when you know
virtually nothing about his program. Then you started up like I was
attacking you for saying that. In any case, this debate is pointless and I'm
done with it.  <g>

--
Mike
Microsoft MVP Visual Basic



Sun, 12 Dec 2010 07:15:16 GMT  
 image size


Quote:


>> No he hasn't. But that's really not relevant..at least I don't
>> think so.  You made the point and he doesn't want to resize
>> images. 'Nuff said.

> No. That is NOT true. You are making things up again! The OP has NEVER in
> this thread said that he does not want to resize images. Why do you insist
> on repeatedly making things up in order to attempt to gain some undeserved
> brownie points?

chill out dood.


Sun, 12 Dec 2010 11:58:11 GMT  
 image size



Quote:





>>> No he hasn't. But that's really not relevant..at least I don't
>>> think so.  You made the point and he doesn't want to resize
>>> images. 'Nuff said.

>> No. That is NOT true. You are making things up again! The OP has NEVER in
>> this thread said that he does not want to resize images. Why do you insist
>> on repeatedly making things up in order to attempt to gain some undeserved
>> brownie points?

>chill out dood.

And the supreme being has spoken, therefore it shall be.

Why don't you chill out, McBarfy?

Frank



Sun, 12 Dec 2010 12:42:20 GMT  
 image size


Quote:







>>>> No he hasn't. But that's really not relevant..at least I don't
>>>> think so.  You made the point and he doesn't want to resize
>>>> images. 'Nuff said.

>>> No. That is NOT true. You are making things up again! The OP has NEVER
>>> in
>>> this thread said that he does not want to resize images. Why do you
>>> insist
>>> on repeatedly making things up in order to attempt to gain some
>>> undeserved
>>> brownie points?

>>chill out dood.

> And the supreme being has spoken, therefore it shall be.

> Why don't you chill out, McBarfy?

My my Mr "dot nyet", aren't you the guy who apologized to folks around here
just a week or so ago and promised no more trolling ?  Seems your
credibility as is good as your word.


Sun, 12 Dec 2010 12:50:20 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Form size and Image size

2. Maximum Image size allowed for Image datatype.

3. Can I get Image size without loading image ???

4. Image Size Problem.MS Excel Chart Export method

5. Adjusting Image Size

6. Changing image size

7. Finding image size

8. Image Size in the database

9. How could I determing Image size

10. Image size (calculation)

11. Help with window/image sizing.

12. Keeping image size within acceptable range

 

 
Powered by phpBB® Forum Software