# How to get image size in vtkimageviewer2 c++?

**URL:** https://discourse.vtk.org/t/how-to-get-image-size-in-vtkimageviewer2-c/3560
**Category:** Support
**Created:** [June 15, 2020, 6:55pm UTC](https://discourse.vtk.org/t/how-to-get-image-size-in-vtkimageviewer2-c/3560 "2020-06-15T18:55:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![beginner](https://discourse.vtk.org/user_avatar/discourse.vtk.org/beginner/32/1930_2.png) [@beginner](https://discourse.vtk.org/u/beginner)
#### Post date: [June 15, 2020, 6:55pm UTC](https://discourse.vtk.org/t/how-to-get-image-size-in-vtkimageviewer2-c/3560/1 "2020-06-15T18:55:35Z")

</div>

Hi everyone,

I’m trying to get the image size using vtkimageviewer2 by using this fcn:  
virtual int\* vtkImageViewer2::GetSize()   
currently, I am getting 0 from _(imagesmartpointer -\> GetSize()). Since the return type is an int_, I dereferenced it but it’s not working. So how do I actually access the image size?

---

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [June 17, 2020, 7:00am UTC](https://discourse.vtk.org/t/how-to-get-image-size-in-vtkimageviewer2-c/3560/2 "2020-06-17T07:00:38Z")

</div>

virtual int vtkImageViewer2::GetSize ( );  
Set/Get the size of the window in screen coordinates in pixels.  
I think you can use GetSliceRange () instead.
