• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

problem in checking the dimensions of an image.

 
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
im doing validations in java code for image upload..im unable to get validated i.e.,if two files are entered it should check for the dimensions.i m unable to code how to check for the dimensions...can anyone help me out...here is the code...


thanks,
madhu.
 
Sheriff
Posts: 22804
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are classes ImageContentArray, ContentResponse and ImageContentData?
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it takes ArrayList in ImageContentArray and ImageContentData and in ContentResponse takes whether the entered userid,key and access..i need is i need to upload image file..if i upload image file it should check for the 'dimensions,filetype'..if i enter the same dimensions then it should through an error...im not getting any idea how to validate the fields...can you help me out.

thanks,
madhu.
 
Rob Spoor
Sheriff
Posts: 22804
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since I know absolutely nothing of your ImageContentData I cannot tell you how to read the dimensions of an image that is apparently contained in it. TellTheDetails.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is my code
1)ImageContentData.java


2)validation.java

can you check it and help me how to code..
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Posting the code of class ImageContentArray does not help us understand how class ImageContentData works.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
then tell me what should be required..i'll post
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should respond to this post:

Rob Prime wrote:Since I know absolutely nothing of your ImageContentData I cannot tell you how to read the dimensions of an image that is apparently contained in it. TellTheDetails.


The response should make it clear how images are stored in class ImageContentData; we may then be able to suggest how to obtain image dimensions.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Madhuri,

Lester and Rob are very much right in their own way. Your question is very specific to a class which would not make sense unless the reader has some background of that.

Anyways...what I could make out on my own is, you have two images and you want to compare them for their height and width.
If I my udnerstanding of your probolem is correct you should see java.awt.Image class.


Pl correct my if I got you wrong.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
im doing application in which im uploading images for suppose im uploading 2 images at a time.I need to check the following conditions
1)check if uploaded images had Duplicate File Name...if i has same File Name..then it should throw an error.
2)check if uploaded images had Duplicate Dimensions...if i has same File Name..then it should throw an error.
and i coded in the following java files
1)contentProp

2)contentResponse.java

3)contentValidation.java

i m not getting idea how to check the conditions for validations in isValidImageContent() method...can any one help me out..
 
Abhishk Gupta
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Madhuri...posting entire code will only make it messy widout much/no description.
e.g. your ContentProperties does not make any sense to me.

you mentioned you want to validate image name and dimension but I dont see that in the code posted. Moreover, I am yet to understand your problem.

Please go through the link provided by Rob TellTheDetails.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Abhishk,
i need to code in

in isValidImageContent() method in validations.java file..i m not getting idea how to code for validations of image upload...can you suggest me how to code..i had mentioned in //need to do validations comment in the code.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you posting code that has nothing to do with image dimensions (which you said was the problem)? Why are you not posting the code of the ImageContentData class?
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the ImageContentData.java
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you have the image contents as a byte[]; that's a good start. There was a discussion about a class called ImageInfo that could figure out image dimensions without knowing which format the image was in. It looks like that class needs an InputStream, which you could get from the byte[] by using a ByteArrayInputStream.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Lester,
i got what you suggested..im developing mobile application.In which user can upload image from internet to his mobile...im writing code if user uploads 2images that should validated...i need to write in for loop..im not getting idea how to check 2 images are same or not...that is my problem..can you suggest me how to code it..
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to check if two images are the same? That's a completely different thing than comparing a filename and dimensions. Which is it?
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi David,
i need to compare a filename and dimensions for the uploaded image...i had wrote wrongly..here i had done some coding..can you check and provide me solution..i searched in net but im not getting any info...
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i had done some validation in uploading my image for my mobile application...im unable to check whether the file is uploaded or not...i used System.out.println statement for verification..but im not getting...can anyone check it and provide me the solution..here is the code and im using console application..
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i used contentResponse for checking purpose...im not getting..any help..
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

madhuri kunchala wrote:
Arrays.equals(imageContentData.getFileBytes(), imageContentData.getFileBytes())
imageContentData.getType().equals(imageContentData.getType())
imageContentData.equals(imageContentData)
imageContentData.getDimesions().equals(imageContentData.getDimesions())


These conditions will always evaluate to true, so they're most likely not what you intended to do.

Also, having "imageContentData.getFileBytes() != null" trigger the "Duplicate File Name" case looks suspicious; did you mean to use "&&" instead of "||"?

Lastly, "imageContentData.getType().trim()" (and the following ones) will never be null, so the check for null is bogus. "imageContentData.getType()", however, could conceivably be null, in which case the "trim()" call would throw an exception. You probably want to check "imageContentData.getType() != null" instead.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Lester,
i had done modifications what you had suggested..eventhough im not getting the System.out.println("hello"); is not getting printed...here is the modified code...
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This looks suspicious: "imageContentData.getFileBytes() == null"

All the "equals" comparisons still don't make sense.

And just to be sure: imageContentDatas contains at least one item, and validContentB is true, yes?
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
validContentB is true...can you suggest where i need to change the code..
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you addressed the first point of my previous post? It's crucial, as is imageContentDatas not being empty.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
k..the ImageContentDatas is an ArrayList and it cant be empty...then how to check or validate the fileds different methods that are checked by the ImageContentData
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lester Burnham wrote:Have you addressed the first point of my previous post? It's crucial, as is imageContentDatas not being empty.


Have you?

madhuri kunchala wrote:..the ImageContentDatas is an ArrayList and it cant be empty


If it can't be empty, then why is there code that checks whether it's empty and creates an error message if it is?

I'm getting the idea that you're not going about this very methodically. At this point I think it would be faster if you inserted System.out.println statements between each two lines of code, and print the values of all variables. Then you'll know how the code behaves and why. (It may be easier to do this using a debugger in your IDE, if you're using one.)
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
k..i'll check it and i'll find out where it goes wrong..
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic