Initialize self._iw and self._ih from the size of the image file if it exists. >>> from pagebot import getContext >>> from pagebot.filepaths import getResourcesPath >>> from pagebot.constants import A4 >>> from pagebot.document import Document >>> con
(self)
| 40 | self.pn = 1 |
| 41 | |
| 42 | def initializeImageSize(self): |
| 43 | """Initialize self._iw and self._ih from the size of the image file if |
| 44 | it exists. |
| 45 | |
| 46 | >>> from pagebot import getContext |
| 47 | >>> from pagebot.filepaths import getResourcesPath |
| 48 | >>> from pagebot.constants import A4 |
| 49 | >>> from pagebot.document import Document |
| 50 | >>> context = getContext() |
| 51 | >>> doc = Document(size=A4, padding=30, context=context) |
| 52 | >>> page = doc[1] |
| 53 | >>> imageFilePath = '/images/peppertom.png' |
| 54 | >>> path = getResourcesPath() + imageFilePath |
| 55 | >>> e = ImageData(path, parent=page) |
| 56 | >>> e.iw, e.ih # Get real size of image in the file |
| 57 | (398pt, 530pt) |
| 58 | """ |
| 59 | if self.path is not None and os.path.exists(self.path): |
| 60 | self._iw, self._ih = self.context.imageSize(self.path) |
| 61 | else: |
| 62 | self._iw = self._ih = pt(0) # Undefined or non-existing, there is no image file. |
| 63 | |
| 64 | def _get_w(self): |
| 65 | """Answers the width of the image if it is defined. If self._w is None, |