Answer the path where scaled images go to, also altering their name. If extension is different from the path extension, then replace it. If w, h, index or extension are set, then add them to the output name. If basePath is None, then used the default ./scaled/ instead. >>> path2Scal
(path, w=None, h=None, index=None, extension=None, scaledPath=None)
| 613 | return path.split('.')[-1].lower() |
| 614 | |
| 615 | def path2ScaledImagePath(path, w=None, h=None, index=None, extension=None, scaledPath=None): |
| 616 | """Answer the path where scaled images go to, also altering their name. If |
| 617 | extension is different from the path extension, then replace it. If w, h, |
| 618 | index or extension are set, then add them to the output name. If basePath |
| 619 | is None, then used the default ./scaled/ instead. |
| 620 | |
| 621 | >>> path2ScaledImagePath('images/myImage.jpg') |
| 622 | 'scaled/myImage.jpg' |
| 623 | >>> path2ScaledImagePath('images/myImage.jpg', 100, 200) |
| 624 | 'scaled/myImage-w100-h200.jpg' |
| 625 | >>> path2ScaledImagePath('images/myImage.jpg', 100, 200, 12, 'png') |
| 626 | 'scaled/myImage-w100-h200-i12.png' |
| 627 | >>> path2ScaledImagePath('images/myImage.jpg', 100, 200, 12, 'jpg', scaledPath='anotherPath') |
| 628 | 'anotherPath/myImage-w100-h200-i12.jpg' |
| 629 | """ |
| 630 | if scaledPath is None: |
| 631 | scaledPath = 'scaled/' |
| 632 | elif not scaledPath.endswith('/'): |
| 633 | scaledPath += '/' |
| 634 | if extension is None: |
| 635 | extension = path2Extension(path) |
| 636 | fileName = '.'.join(path2Name(path).split('.')[:-1]) |
| 637 | params = [] |
| 638 | if w: |
| 639 | params.append('w%s' % w) |
| 640 | if h: |
| 641 | params.append('h%s' % h) |
| 642 | if index is not None: |
| 643 | params.append('i%s' % index) |
| 644 | params = '-'.join(params) |
| 645 | if params: |
| 646 | params = '-' + params |
| 647 | return scaledPath + fileName + params + '.' + extension |
| 648 | |
| 649 | def path2FontName(path, extensions=None): |
| 650 | """ |
no test coverage detected