# Perspective File Upload - tablet picture size

**URL:** <https://forum.inductiveautomation.com/t/perspective-file-upload-tablet-picture-size/105385>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 22, 2025, 1:03pm UTC](https://forum.inductiveautomation.com/t/perspective-file-upload-tablet-picture-size/105385 "2025-04-22T13:03:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [April 22, 2025, 1:03pm UTC](https://forum.inductiveautomation.com/t/perspective-file-upload-tablet-picture-size/105385/1 "2025-04-22T13:03:08Z")

</div>

Is there a way to request the camera to restrict the size of pictures taken? My project needs two small pictures that would be displayed or printed in a "thumbnail" size, approximately 200x200 pixels. A 6mb picture is way too big for this use. I thought about limiting the file size in the component, but I don't think that would force the camera to downsize the photo.

Thanks!

edit: For future people, this is what I ended up with in the `onFileReceived` event to solve my issue. Forgive my dirty code.

```python
def runAction(self, event):
	from io import BytesIO
	from java.io import ByteArrayInputStream
	from java.io import ByteArrayOutputStream
	from javax.imageio import ImageIO
	from java.awt import Image
	from java.awt.image import BufferedImage
	
	pic_data = event.file.getBytes()
	stream = ByteArrayInputStream(pic_data)
	original_image = ImageIO.read(stream)
	
#	set target size and preserve aspect ratio
	target_width = 640
	original_width = original_image.getWidth(None)
	original_height = original_image.getHeight(None)
	ratio = float(original_height) / float(original_width)
	target_height = int(target_width * ratio)

#	rescale
	scaled = original_image.getScaledInstance(target_width, target_height, Image.SCALE_SMOOTH)
	
#	buffer image for writing
	buffered = BufferedImage(target_width, target_height, BufferedImage.TYPE_INT_RGB)
	g = buffered.createGraphics()
	g.drawImage(scaled, 0, 0, None)
	g.dispose()
	
#	encode to JPEG
	out = ByteArrayOutputStream()
	ImageIO.write(buffered, 'jpg', out)
	out.flush()
	rescaled_data = out.toByteArray()
	out.close()

```

this takes a 7mb image from an ipad and shrinks the file size to 27k

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 22, 2025, 1:19pm UTC](https://forum.inductiveautomation.com/t/perspective-file-upload-tablet-picture-size/105385/2 "2025-04-22T13:19:29Z")

</div>

No, but you could use java's ImageIO to decipher the file and then rescale it on the gateway before you store it.

---

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [April 23, 2025, 2:18pm UTC](https://forum.inductiveautomation.com/t/perspective-file-upload-tablet-picture-size/105385/3 "2025-04-23T14:18:11Z")

</div>

Thank you!

I updated my original post with the code I used to accomplish this. There's probably a cleaner way to do it. Thanks again for pointing me in the right direction.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 23, 2025, 2:45pm UTC](https://forum.inductiveautomation.com/t/perspective-file-upload-tablet-picture-size/105385/4 "2025-04-23T14:45:57Z")

</div>

> [@hw79](#):
>
> cleaner way

Yes, your code should be a function in a project library script, so you can do your imports _outside_ the function, along with constants like `target_width`. The actual `runAction` event script should be a one-liner delegating to the project library function.
