* **I'm submitting a:**
  - [x] Bug report

* **[Bug report] What is the current behavior?**
inside the `loadFromTiffHandle` every time an exception is about to be raised, the function `TIFFClose` is being called and then the exception is raised. The exception is caught in `loadFromTiff` and `TIFFClose` gets called again which tries to close a TIFF file that is already closed.

* **[Bug report] What is the expected behavior?**
All of the calls to `TIFFClose` inside the `loadFromTiffHandle` should be removed and only the one in `loadFromTiff` should remain.
even better would be to use a wrapper class like this inside `loadFromTiff` and never use `TIFFClose` anywhere else:
```
class TTiffWrapper
{
protected:
	TIFF* hInfile;
public:
	TTiffWrapper(void);
	TTiffWrapper(const std::string& aPath);
	virtual ~TTiffWrapper(void);
	bool Open(const std::string& aPath);
	void Close(void);
	TIFF* operator&(void);
	void SetCurrentPage(const unsigned int cPage);
	bool GetIsOpen(void) const;

	__declspec(property(get = GetIsOpen)) bool IsOpen;
};

TTiffWrapper::TTiffWrapper(void)
{
    hInfile = nullptr;
}

TTiffWrapper::TTiffWrapper(const std::string& aPath)
{
    Open(aPath);
}

TTiffWrapper::~TTiffWrapper(void)
{
    Close();
}

bool TTiffWrapper::Open(const std::string& aPath)
{
    Close();
    hInfile = TIFFOpen(aPath.data(), "rb");

    return (nullptr != hInfile);
}

void TTiffWrapper::Close(void)
{
    if (nullptr != hInfile)
    {
        TIFFClose(hInfile);
        hInfile = nullptr;
    }
}

TIFF* TTiffWrapper::operator&(void)
{
    return hInfile;
}

void TTiffWrapper::SetCurrentPage(const unsigned int cPage)
{
    if (nullptr != hInfile)
        TIFFSetDirectory(hInfile, cPage);
}

bool TTiffWrapper::GetIsOpen(void) const
{
    return (nullptr != hInfile);
}
```
When using the class above, the & operator can be used as parameter to `loadFromTiffHandle`.

* **[Bug report] Please provide the steps to reproduce and if possible a minimal reproduction code of the problem**
* try to load a Tiled TIFF
  
  - Version/git revision: [0.10.3]
  - Operating System: [Windows 11 (64 bits)]
  - Package manager used: [source]
multiple use of TIFFClose on the same TIFF handle
This is a GitHub Issue
repo:podofo
owner:podofo
Title : multiple use of TIFFClose on the same TIFF handle
Issue date:

--- start body ---
* **I'm submitting a:**
  - [x] Bug report

* **[Bug report] What is the current behavior?**
inside the `loadFromTiffHandle` every time an exception is about to be raised, the function `TIFFClose` is being called and then the exception is raised. The exception is caught in `loadFromTiff` and `TIFFClose` gets called again which tries to close a TIFF file that is already closed.

* **[Bug report] What is the expected behavior?**
All of the calls to `TIFFClose` inside the `loadFromTiffHandle` should be removed and only the one in `loadFromTiff` should remain.
even better would be to use a wrapper class like this inside `loadFromTiff` and never use `TIFFClose` anywhere else:
```
class TTiffWrapper
{
protected:
	TIFF* hInfile;
public:
	TTiffWrapper(void);
	TTiffWrapper(const std::string& aPath);
	virtual ~TTiffWrapper(void);
	bool Open(const std::string& aPath);
	void Close(void);
	TIFF* operator&(void);
	void SetCurrentPage(const unsigned int cPage);
	bool GetIsOpen(void) const;

	__declspec(property(get = GetIsOpen)) bool IsOpen;
};

TTiffWrapper::TTiffWrapper(void)
{
    hInfile = nullptr;
}

TTiffWrapper::TTiffWrapper(const std::string& aPath)
{
    Open(aPath);
}

TTiffWrapper::~TTiffWrapper(void)
{
    Close();
}

bool TTiffWrapper::Open(const std::string& aPath)
{
    Close();
    hInfile = TIFFOpen(aPath.data(), "rb");

    return (nullptr != hInfile);
}

void TTiffWrapper::Close(void)
{
    if (nullptr != hInfile)
    {
        TIFFClose(hInfile);
        hInfile = nullptr;
    }
}

TIFF* TTiffWrapper::operator&(void)
{
    return hInfile;
}

void TTiffWrapper::SetCurrentPage(const unsigned int cPage)
{
    if (nullptr != hInfile)
        TIFFSetDirectory(hInfile, cPage);
}

bool TTiffWrapper::GetIsOpen(void) const
{
    return (nullptr != hInfile);
}
```
When using the class above, the & operator can be used as parameter to `loadFromTiffHandle`.

* **[Bug report] Please provide the steps to reproduce and if possible a minimal reproduction code of the problem**
* try to load a Tiled TIFF
  
  - Version/git revision: [0.10.3]
  - Operating System: [Windows 11 (64 bits)]
  - Package manager used: [source]
--- end body ---
