Package: markdown-img-icexmoon
Markdown-img User's GuideEnglish |简体中文ContentsProject AddressUsageNotes for detailsSupported image bed servicesInstallUpdateFunctionView the help fileView the version and configuration informationSelect working languageGenerate a markdown copy of the image bedRestore local gallery from the image bedSwitching the image bed serviceUpdate the image bed acess tokenScan images and create indexesRefreshing a copy of the image bedBacking up the system configurationList saved configurationsReplacing configurationsRelative path imageAcknowledgementsUpdate LogProject Addresspypi：https://pypi.org/project/markdown-img-icexmoon/github：https://github.com/icexmoon/markdown-imgPersonal Blog：https://blog.icexmoon.xyz/?p=99UsageThis program is used to scan the markdown files in the working directory, find the local images in them and upload them to thesm.msimage bed automatically, and generate a copy of the markdown using the network images to replace the local images, which is stored in thecurrent_working_directory/markdown_imagedirectory.By the above way, we can realize the automatic batch markdown image processing work to facilitate the later dissemination of markdown contents on the web.Notes for detailsThis program will not change the original markdown file, please feel free to use it.This program relies onsm.msimage bed, please register your account and generate token by yourself.Support for other image beds has been added, see features for details, but the default is still using sm.ms image bed.Because thesm.msimage bed interface has a call limit, if there is a picture upload error, it may be caused by frequent uploads, please wait for more than 1 minute and reuse this program.Tencent Cloud Object Storage has been added as a image bed, when using it, you need to enter the corresponding mandatory parameters for connection, you can read theTencent Cloud OSS User Guidefor specific parameters, in addition, you need to set the object storage service to private write public read.Currently this program only supports windows.Theoretically supports all platforms that can run Python, but has not been tested on other platforms at this time.sm.msaccess is not considered friendly in China, generated markdown copy immediately published on the network may show anti-theft chain and other images hanging, that is because the domestic CDN is relatively slow, wait for a period of time on the good.This program is written in Python, you need to install the Python runtime environment, if you don't know how to install, you can read thepython environment installation under windows.Supported image bed servicesImage bed nameFlagBed natureAccess token requiredNotessm.mssmmsPublicYesDefault image bed, foreign old public image bed service provider, trustworthy, the disadvantage of domestic access is unstable.yujianyujianPublicYesA domestic image bed service, in addition to providing its own image bed service, also supports calling other image bed services through its API.ruyourruuPublicYesAs you can see and met with the same set of website code, the site is currently closed, the service is not available.alialiPublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.Vim-CNvimcnPublicNoA foreign bed service provider, said to be the same old service provider, the same disadvantage of domestic access is unstable.Tencent Cloud COSqcloudPrivateYesThere is nothing to say, several private cloud storage in the most recommended, the disadvantage is that currently only provides a year of free credit, the expiration of the need to renew.Qiniu CloudqiniuPrivateYesProvide permanent free storage quota, the disadvantage is not to provide a domain name for the stored external links, you need to own a domain name and binding operation before you can use it.bilibilibilibiliPublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.SougousougouPublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.HuluxiahuluxiaPublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.CatboxcatboxPublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.360360PublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.TietupostimagesPublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.58ai58PublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.JitugtimgPublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.BaitubkimgPublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.MukemukePublicYesUnusual service, supported by the API implementation of yujian image bed, used with caution.Upay CloudupyunPrivateYesProvide vouchers, the disadvantage is not to provide a domain name for the stored external links, you need to own a domain name and binding operation before you can use it. In addition, white whoring vouchers need to join theAlliance, and once a year audit.Installpipinstallmarkdown-img-icexmoonUpdatepipinstall--upgrademarkdown-img-icexmoonFunctionAdded console short command support, all functions can be called quickly viapymdimg.For example,pymdimg -his exactly the same aspython -m markdown_img -h.View the help fileExecutepython -m markdown_img -h。View version and configuration informationExcutepymdimg -vorpymdimg --version.Select working languageEnglish and Chinese are supported as working languages, the default is Chinese.Executepymdimg -l ento switch the working language.Image CompressionEnabling this feature will compress images over a certain size and then upload them to the image bed to save private storage space. The compressed intermediate images will be automatically deleted from the local area and will not affect the original local images.Executepymdimg --compressto set the relevant configuration and then turn it on.Switching image compression enginesGIL and tinyPNG are currently supported, the former for local compression using a third-party Gillow package, and the latter for online compression using the online service tinyPNG.com, the latter is recommended because the latter is lossless compression, but the latter requires registration to generate an access token first, and free users have the number of calls: 500 per month.Executepymdimg -e tinyPNGto switch.Generate a markdown copy of the image bedThe main function of this program, will scan the markdown file in the command line working directory, will replace the local image in it with a bed image and then generate a copy of the bed, the generated copy will be stored in themarkdown_imgfolder in the working directory.Use CMD to locate the directory where the markdown file will be processed.Executepython -m markdown_img.The first time you run the program you will be prompted to enter the markdown token.Enter it and execute step 2 again.Wait for processing.When you are done, check theworking_directory/markdown_imgdirectory.The token is stored in themain.configfile in the directory where the program is located. You can modify it yourself if you need to, or you can delete the configuration file and run the program again to enter it.The command parameters of the program will be enriched and refined later.If the URL returned by the target image bed contains special characters such as Chinese or spaces, and your markdown text editor cannot preview the corresponding image properly, you may need to use URL ENCODE to process it, turn on this function bypymdimg -u standard, and regenerate the copy after turning on. This feature currently only works with Tencent OSS, because other image beds will not return Chinese URLs.A copy can be generated using a specified configuration, such aspymdimg --config normal, which allows you to use a customized related configuration to complete this task without modifying the current configuration in specific scenarios, such as when you want compression not to apply in this task, or when you use large scale compression. See [Function: Backup system configuration] for the specific function of making related configurations.Restore local gallery from the image bedIf the copy of the image bed is intact, but the local images associated with the native markdown file are missing, you can use this function to try to recover them.Switch the command line working directory to the directory of the markdown file you want to restore.Excutepython -m markdown_img -m img_recoveWait for processing.Check if the local markdown file image is restored after it is finished.Because the network image bed is unstable, although the program itself has a timeout reconnection mechanism, if too many images are recovered, it is likely that the processing will be interrupted and the program will simply need to be rerun.The recovery logic is to compare the order of appearance of the images in the copy and the original, and recover them 1 to 1. So it is important to ensure that there is no difference between the two, and the program will interrupt when the number of both is different and prompt the user to confirm manually.Switching the image bed serviceYou can switch the image bed service in case a certain image bed is not available or the access is unstable.Currently supported image beds aresm.ms, Ali,RuYu,Vim-CN,meet,Tencent cloud object storage(promotional link),Qiniu Cloud.For a list of supported image beds, seeSupported Image Bed Services.Excutepython -m markdown_img -i aliYou can check the help documentation for the specific image bed logo.Access tokens are required to switch the bed service and will be prompted to enter the appropriate access token in use.Some necessary information is required to use Tencent Cloud OSS, please read the notes for details.You need to provide the necessary information when using Qiniu Cloud Storage, where the DNS binding domain name needs to include the protocol, such ashttp://example.domain.comUpdate the image bed access tokenIf a wrong access token is set for the image bed token, or if a new access token is regenerated on the image bed website, you can update the corresponding access token in the program.Excutepython -m markdown_img -c smmsYou can check the help documentation for specific parameters.Part of the image bed configuration if more than one, you can use subcommands to modify only a single configuration, for example, only modify the Tencent cloud storage directory:pymdimg -c qcloud --des_dir image, if there are spaces in the middle of the target directory, you need to give will be wrapped in English double quotes, such as this:pymdimg -c qcloud --des_dir "我 love 你". After updating the configuration you can usepymdimg -vto confirm that the configuration has been set correctly.Scan images and create indexesIf you need to upload all the images in a directory to a webbed and create a markdown file as an index file, then this is the right function to use.python-mmarkdown_img-sThe index file will be regenerated each time it is run.The name of the generated index file ismarkdown_img_index.md, please make sure not to customize the file with the same name in the target directory.You can use the specified configuration, such aspymdimg -s --config normal, as described in the relevant entry in [Generating a copy of the mapbed markdown].Refreshing a copy of the image bedIf your original md file has been updated and you don't want to delete the corresponding copy file manually and want to regenerate it automatically, you can use this function.python-mmarkdown_img-mrefreshScans the current directory for the original md file, and if there is no copy, creates it directly. If there is a copy, but the original file is "newer" than the copy, the copy is recreated.Backing up the system configurationIf necessary, the system configuration can be backed up bypymdimg-mbackup_config--namexxxThe--nameparameter is not required, if not specified a configuration backup file name will be generated based on the current time.List saved configurationspymdimg--list_configwill list the configuration name and creation timeReplacing configurationsYou can replace the current configuration with a saved configuration:pymdimg--change_configxxxwherexxxis the file name of the saved configuration you want to replace. To see what saved configurations are available, please use [Function: List saved configurations]. In addition, it is better to save the current configuration before using this function.Relative path imageYou can process the MD file using absolute path pictures to use relative path pictures, and the program will copy the original pictures to the images subdirectory of the current directory as relative path pictures.The purpose of this function is to provide convenience for some cross-platform, multi-device users, using relative paths, raw images and MD files can be easily moved, or using a synchronization service similar to Nut Cloud for multi-device synchronization.pymdimg-mrelative_imgIn order to avoid the corruption of the original MD file caused by program errors, one original file will be kept and backed up in the backup subdirectory.Because of the difference between Windows and Linux platform separators, there is no guarantee that the relative directories of both will behave properly.AcknowledgementsThe developer of this application has received help and support fromupyunfor its free CDN acceleration and cloud storage services, if you want to get the same help and support, you can Clickhereto join.Update Log0.2.8Add globalization support. add English as a new working language.0.2.9Add Qiniu Cloud as a new optional image bed.0.3.0Code refactoringAdd bilibili as new image bedFix some bugs0.3.1Add UPYun Cloud as a new optional image bed.0.3.2Add image compression feature.0.3.3Add TinyPNG as a new image compression engine.0.3.4Compression engine switch option add none, can be more convenient to turn off the compression function.0.3.5Add system configuration backup function.0.3.6Add the function of using specified configuration.0.3.7Fix the bug that can't install successful caused by use futures module.0.3.8Fix the bug that can't create img dir normally in Linux.0.3.9Added the function to modify the absolute path image in the MD file to relative path.0.4.0Added the support to fengzhen image bed.