images_upload_cli
¶
Public accessible objects of that module.
image
¶
Image processing and manipulation.
get_img_ext
¶
Get the extension of an image from a byte string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
bytes
|
A byte string representing an image. |
required |
Returns:
Type | Description |
---|---|
str
|
The extension of the image file. |
Source code in src/images_upload_cli/image.py
11 12 13 14 15 16 17 18 19 20 21 22 |
|
get_font
¶
get_font(size: int = 14) -> FreeTypeFont
Get font for thumbnail captions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
int
|
The size of the font. Defaults to 14. |
14
|
Returns:
Type | Description |
---|---|
FreeTypeFont
|
ImageFont.FreeTypeFont: Represents the font. |
Source code in src/images_upload_cli/image.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
search_font
¶
search_font(fonts: list[str], size: int = 14) -> FreeTypeFont
Attempt to retrieve a TTF font from the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fonts |
list[str]
|
A list of font names to search for. |
required |
size |
int
|
The font size. Defaults to 14. |
14
|
Returns:
Type | Description |
---|---|
FreeTypeFont
|
ImageFont.FreeTypeFont: Represents the font. |
Raises:
Type | Description |
---|---|
GetEnvError
|
If none of the default fonts are found. |
Source code in src/images_upload_cli/image.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
make_thumbnail
¶
Generate thumbnail for the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
bytes
|
The input image in bytes format. |
required |
font |
FreeTypeFont
|
The font to be used for the text caption. |
required |
size |
tuple[int, int]
|
The desired size of the thumbnail image. Defaults to (300, 300). |
(300, 300)
|
Returns:
Type | Description |
---|---|
bytes
|
The modified image in bytes format. |
Source code in src/images_upload_cli/image.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
logger
¶
Logger configuration.
ErrorHandler
¶
ErrorHandler()
Bases: StreamHandler
Custom error handler for logging.
Source code in src/images_upload_cli/logger.py
12 13 14 15 |
|
setup_logger
¶
setup_logger(log_level: str) -> ErrorHandler
Configure logger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_level |
str
|
The log level to set for the logger. |
required |
Returns:
Name | Type | Description |
---|---|---|
ErrorHandler |
ErrorHandler
|
The error handler associated with the logger. |
Source code in src/images_upload_cli/logger.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
main
¶
Main logic for the images-upload-cli package.
upload_images
async
¶
upload_images(upload_func: Callable[[AsyncClient, bytes], Awaitable[str]], images: tuple[Path], thumbnail: bool) -> Sequence[tuple[str, str] | tuple[str, None]]
Upload images using the specified upload function and optionally generate thumbnails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload_func |
Callable[[AsyncClient, bytes], Awaitable[str]]
|
The function used to upload the images. |
required |
images |
tuple[Path]
|
The paths of the images to be uploaded. |
required |
thumbnail |
bool
|
Indicates whether to generate thumbnails for the images. |
required |
Returns:
Type | Description |
---|---|
Sequence[tuple[str, str] | tuple[str, None]]
|
The links to the uploaded images and their corresponding thumbnails. |
Sequence[tuple[str, str] | tuple[str, None]]
|
The thumbnail link will be |
Source code in src/images_upload_cli/main.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
format_link
¶
Format the image links based on the specified format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
links |
Sequence[tuple[str, str] | tuple[str, None]]
|
The image links and their corresponding thumbnails. |
required |
fmt |
str
|
The format to use for formatting the links. Valid options are "plain", "bbcode", "html", and "markdown". |
required |
Returns:
Type | Description |
---|---|
str
|
The formatted image links as a string. |
Source code in src/images_upload_cli/main.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
upload
¶
Upload images to various hosting services.
anhmoe_upload
async
¶
Uploads an image to the anh.mo
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
beeimg_upload
async
¶
Uploads an image to the beeimg.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
catbox_upload
async
¶
Uploads an image to the catbox.moe
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
fastpic_upload
async
¶
Uploads an image to the fastpic.org
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
filecoffee_upload
async
¶
Uploads an image to the file.coffee
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
freeimage_upload
async
¶
Uploads an image to the freeimage.host
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
gyazo_upload
async
¶
Uploads an image to the gyazo.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
imageban_upload
async
¶
Uploads an image to the imageban.ru
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
imagebin_upload
async
¶
Uploads an image to the imagebin.ca
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
imgbb_upload
async
¶
Uploads an image to the imgbb.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
|
imgchest_upload
async
¶
Uploads an image to the imgchest.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
imgur_upload
async
¶
Uploads an image to the imgur.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
lensdump_upload
async
¶
Uploads an image to the lensdump.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
|
pixeldrain_upload
async
¶
Uploads an image to the pixeldrain.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
pixhost_upload
async
¶
Uploads an image to the pixhost.to
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
|
ptpimg_upload
async
¶
Uploads an image to the ptpimg.me
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
smms_upload
async
¶
Uploads an image to the sm.ms
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
|
sxcu_upload
async
¶
Uploads an image to the sxcu.net
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
telegraph_upload
async
¶
Uploads an image to the telegra.ph
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
|
thumbsnap_upload
async
¶
Uploads an image to the thumbsnap.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|
tixte_upload
async
¶
Uploads an image to the tixte.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
|
up2sha_upload
async
¶
Uploads an image to the up2sha.re
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
|
uplio_upload
async
¶
Uploads an image to the upl.io
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
|
uploadcare_upload
async
¶
Uploads an image to the uploadcare.com
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
|
vgy_upload
async
¶
Uploads an image to the vgy.me
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
AsyncClient
|
The async HTTP client used to make the API request. |
required |
img |
bytes
|
The image data to be uploaded. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the uploaded image, or an empty string if the upload failed. |
Source code in src/images_upload_cli/upload.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
|
util
¶
Utility functions for the package.
get_config_path
¶
get_config_path() -> Path
Get the path to the app config file.
Returns:
Type | Description |
---|---|
Path
|
The path to the app config file. |
Source code in src/images_upload_cli/util.py
17 18 19 20 21 22 23 24 |
|
get_env
¶
Get the value of an environment variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variable |
str
|
The name of the environment variable to retrieve. |
required |
Returns:
Type | Description |
---|---|
str
|
The value of the environment variable, if found. |
Raises:
Type | Description |
---|---|
GetEnvError
|
If the environment variable is not found. |
Source code in src/images_upload_cli/util.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
human_size
¶
Convert bytes to human-readable format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num |
float
|
The number of bytes to be converted. |
required |
suffix |
str
|
The suffix to be appended to the converted size. |
'B'
|
Returns:
Type | Description |
---|---|
str
|
The human-readable size with the appropriate unit and suffix. |
Source code in src/images_upload_cli/util.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
notify_send
¶
notify_send(text_to_print: str) -> None
Send desktop notifications via libnotify.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text_to_print |
str
|
The text to be displayed in the desktop notification. |
required |
Source code in src/images_upload_cli/util.py
67 68 69 70 71 72 73 74 |
|
log_on_error
¶
log_on_error(response: Response) -> None
Logs an error message based on the HTTP response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response |
Response
|
The HTTP response object. |
required |
Source code in src/images_upload_cli/util.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|